-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Segfault while compiling package using a foreign type #700
Comments
I wonder why the difference: why is the type being deserialized here before Am I right in this guess how things work? |
tl;dr: it seems that when using
PackageCompiler.create_sysimage
, if module A depends on module B, then it can happen that the precompiled data forA
is deserialized beforeB.__init__
was run. This causes a crash whenA
is referencing a foreign type which is provided byB.__init__
at runtime only.(Disclaim: I realize the following may be "my fault", and I am willing to work on fixing it, but I simply don't understand the various moving parts and components enough to do it on my own, so I hope to get some help here).
The following issue happens with all Julia versions I tested from 1.6 to current master. This is with PackageCompiler 2.0.6 in case it matters.
The GAP.jl package is a wrapper around the computer algebra system GAP. For various reasons, people are interested to run
PackageCompiler.jl
on code using GAP.jl (among many other things). Unfortunately, this segfaults (see here for the initial report. A minimal reproducer: addPackageCompiler
toGAP
to a fresh project, then:Analyzing this further, I've determined that it crashes deserializing the type
GAP_jll.GapObj
(which was precisely what I expected to see once I saw the initial report...). I'll get into background in a moment, let me just quote the code in functionjl_deserialize_value_any
in which the crash happens:The reason it crashes is because
jl_get_global(m, sym)
(withm = GAP_jll
,sym = :GapObj
) returns a NULL pointer...Some background: that type is a "foreign type", a very special kind of type that as far as I know is used precisely by GAP.jl resp. GAP_jll.jl and nothing else. As such, it is not surprising to find things that don't work well with such types, as they were never written with them in mind (indeed, see this issue for some discussions on issues with precompilation etc.).
Aaaanyway: instances of such foreign types can not be (de)serialized; in fact there is a check in
dump.c
that prevent serializing such instances.However, so far serializing the foreign type itself worked fine. Indeed, I've inserted the following right before the crashing line with the
jl_unwrap_unionall
call, in Juliamaster
::If I just do
using GAP
in a Julia session, I see this, among many other things:But with the above PackageCompiler call, I see this:
So, this looks to me as if it is trying to deserialize the type before the
__init__
method ofGAP_jll
has been run, which is responsible for initializingGAP_jll.GapObj
.--
So far, so good. But now how to fix this?
Any pointers would be greatly appreciated!
The text was updated successfully, but these errors were encountered: