Skip to content
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

PackageCompiler on GLMakie --> display(fig) --> segfault 11 on macos Sonoma 14.6.1 #4571

Closed
3 tasks done
johnrfrank opened this issue Nov 5, 2024 · 7 comments
Closed
3 tasks done
Labels

Comments

@johnrfrank
Copy link

I wrote a toy app that let's you zoom on the Mandelbrot set. It is at https://github.com/johnrfrank/MandelbrotZoom/

and you can run the app like this:

julia --project=MandelbrotZoom MandelbrotZoom/src/MandelbrotZoom.jl

That works just fine. It works because it calls wait(display(fig))

but!

If you compile it like this:

julia -e '''
using PackageCompiler

create_app("MandelbrotZoom", "output", incremental = true)
'''

then you get an executable that almost works... it prints out messages up to where it calls display(fig) and then it does this:

...
...
Precompiling project...
  21 dependencies successfully precompiled in 135 seconds. 264 already precompiled.
✔ [02m:36s] PackageCompiler: compiling incremental system image
ld: warning: reexported library with install name '@rpath/libunwind.1.dylib' found at '/Applications/Julia-1.11.app/Contents/Resources/julia/lib/julia/libunwind.1.0.dylib' couldn't be matched with any parent library and will be linked directly
ld: warning: reexported library with install name '@rpath/libunwind.1.dylib' found at '/Applications/Julia-1.11.app/Contents/Resources/julia/lib/julia/libunwind.1.0.dylib' couldn't be matched with any parent library and will be linked directly
$
$
$ ./output/bin/MandelbrotZoom 
Draw the famous picture.
Wait for the display to be done...

[57813] signal 11 (2): Segmentation fault: 11
in expression starting at none:1
_platform_memmove at /usr/lib/system/libsystem_platform.dylib (unknown line)
Allocations: 741726 (Pool: 741663; Big: 63); GC: 3
Segmentation fault: 11
$ 

  • version of Makie and GLMakie

    [ee78f7c6] Makie v0.21.15
    [e9467ef8] GLMakie v0.10.15

  • can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)

Yes, the segfault happens after compiling with PackageCompiler

  • What platform + GPU are you on?

MacBook 2021 Apple M1 Max
macos Sonoma 14.6.1

GLFW.GetVersionString()
"3.4.0 Cocoa NSGL Null EGL OSMesa monotonic dynamic"

@johnrfrank johnrfrank added the bug label Nov 5, 2024
@SimonDanisch
Copy link
Member

Looks like a package compiler / Julia issue to me

@JamesWrigley
Copy link
Contributor

Looks a bit like this issue: JuliaImGui/CImGui.jl#146

I see that the package creates the Figure in the module itself: https://github.com/johnrfrank/MandelbrotZoom/blob/3bd2976d55ebdb34a0ae13402178a55dee396ed2/MandelbrotZoom/src/MandelbrotZoom.jl#L24
What if you create the figure at runtime instead?

@SimonDanisch
Copy link
Member

Oh, didn't look at the code...
Yeah that's a no-go! Good catch!

@JamesWrigley
Copy link
Contributor

BTW, why is creating a Figure in global scope bad? 👀

@SimonDanisch
Copy link
Member

Because it gets run at compile time, and will get baked into the shared library with all their pointers etc. This will include references to GPU memory and c libraries, tasks etc, which all won't be valid anymore when running the binary.

@JamesWrigley
Copy link
Contributor

Ahh I see, thanks.

@johnrfrank
Copy link
Author

Thank you for the explanation! This does fix it.

Here's the refactoring to make it work:

DarwinGalactic/MandelbrotZoom@da9ae39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants