-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid bitcast
and LLVM ERROR: Broken function found, compilation aborted!
when including PyCall in system image
#31473
Comments
This seems like a bug in Julia — user code should not be able to trigger an LLVM error (unless it is doing a raw One crude way to debug is to try deleting code from PyCall until the error goes away, to boil it down to a minimal module exhibiting the failure. |
OK. I think that's doable. Let me also note that JuliaPy/PyCall.jl#668 seems to invoke segfault in a non-deterministic manner in LLVM function (see JuliaPy/PyCall.jl#670). Maybe it's related? |
You can also try a julia debug + LLVM assertion build. From the short snippet this should probably be a |
@vchuravy Thanks. So I build $ cat Make.user
LLVM_ASSERTIONS = 1
$ make julia-debug (Is it what you mean by "julia debug + LLVM assertion build"?) Then executing
Does this help locating the bug? |
It looks like the error is due to the way diff --git a/src/pytype.jl b/src/pytype.jl
index a88121f..7498d8b 100644
--- a/src/pytype.jl
+++ b/src/pytype.jl
@@ -412,9 +412,11 @@ const Py_TPFLAGS_HAVE_STACKLESS_EXTENSION = Ref(0x00000000)
# use this to create a new jlwrap type, with init to set up custom members
function pyjlwrap_type!(init::Function, to::PyTypeObject, name::AbstractString)
sz = sizeof(Py_jlWrap) + sizeof(PyPtr) # must be > base type
PyTypeObject!(to, name, sz) do t::PyTypeObject
- t.tp_base = ccall(:jl_value_ptr, Ptr{Cvoid}, (Ref{PyTypeObject},), jlWrapType)
+ # Not using `Ref{PyTypeObject}` to avoid
+ # https:/JuliaLang/julia/issues/31473
+ t.tp_base = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), jlWrapType)
ccall((@pysym :Py_IncRef), Cvoid, (Any,), jlWrapType)
init(t)
end
end |
@yuyichao, it used to use (We can of course use |
Actually, maybe in this case @yuyichao's comment in the source code is wrong: since I'm not sure why we aren't just calling |
I'm still worried about the best way to implement this code in PyCall. It seems like it would be better for us to do |
It's also correct for all other ones, but it's not more or less correct than the Ref version. This actually seems to be a regression from 0.6 likely when Ptr is represented by a integer. |
Reopening since @yuyichao thinks it is a probably a Julia bug. |
Technically true but we have enough code assuming it after this becomes the case I won't really worry about this get silently changed back. There is still a difference between the two, namely whether your pointer need the tag, |
For a mutable object, they are defined to be the same. Annotating with |
I'm trying to make PyCall.jl compatible with PackageCompiler.jl in JuliaPy/PyCall.jl#651. This branch itself has been working. You can check it with
However, merging JuliaPy/PyCall.jl#668
breaks AOT-compilation with the following error (sandwiched by some logging messages and a stacktrace):
(Here is an example of the full output: https://travis-ci.org/JuliaPy/PyCall.jl/jobs/511050638#L761-L763)
Does this mean there is a function in JuliaPy/PyCall.jl#668 that invokes a bug in Julia compiler? How do I debug more?
cc: @stevengj
The text was updated successfully, but these errors were encountered: