Segmentation fault in executable after compilation with juliac including --trim --experimental arguments

I’m trying out the juliac compilation functionality and I’m getting segmentation faults in my executable.

My code I try to compile:

module ABCD

Base.@ccallable function main()::Cint
    return 0
end

end # Module ABCD

I then try to compile using the following command:

julia +nightly juliac.jl --output-exe try --trim --experimental tryJuliaC.jl

Firstly, I already get a warning using the latest nightly julia version:

WARNING: Detected access to binding `ABCD.main` in a world prior to its definition world.
  Julia 1.12 has introduced more strict world age semantics for global bindings.
  !!! This code may malfunction under Revise.
  !!! This code will error in future versions of Julia.
Hint: Add an appropriate `invokelatest` around the access to this binding.

But the executable is still created, when trying to execute it with ./try, I’m getting the following output:

[12211] signal 11 (1): Segmentation fault
in expression starting at none:0
jl_symbol_name_ at /cache/build/tester-amdci5-9/julialang/julia-master/src/julia.h:1429 [inlined]
jl_generate_ccallable at /cache/build/tester-amdci5-9/julialang/julia-master/src/codegen.cpp:8053
jl_compile_extern_c_impl at /cache/build/tester-amdci5-9/julialang/julia-master/src/jitlayers.cpp:810
jl_compile_extern at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:2475 [inlined]
jl_reinit_ccallable at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:2487 [inlined]
jl_restore_system_image_from_stream_ at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:3981
jl_restore_system_image_from_stream at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:4154 [inlined]
ijl_restore_system_image_data at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:4219
jl_load_sysimg_so at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:663 [inlined]
ijl_restore_system_image at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:4190
_finish_julia_init at /cache/build/tester-amdci5-9/julialang/julia-master/src/init.c:884
julia_init at /cache/build/tester-amdci5-9/julialang/julia-master/src/init.c:864
static_init at /tmp/jl_lCDPQt/init.c:5
__libc_csu_init at ./try (unknown line)
__libc_start_main at /lib64/libc.so.6 (unknown line)
_start at ./try (unknown line)
Allocations: 0 (Pool: 0; Big: 0); GC: 0

[12211] signal 11 (1): Segmentation fault
in expression starting at none:0
jl_symbol_name_ at /cache/build/tester-amdci5-9/julialang/julia-master/src/julia.h:1429 [inlined]
jl_generate_ccallable at /cache/build/tester-amdci5-9/julialang/julia-master/src/codegen.cpp:8053
jl_compile_extern_c_impl at /cache/build/tester-amdci5-9/julialang/julia-master/src/jitlayers.cpp:810
jl_compile_extern at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:2475 [inlined]
jl_reinit_ccallable at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:2487 [inlined]
jl_restore_system_image_from_stream_ at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:3981
jl_restore_system_image_from_stream at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:4154 [inlined]
ijl_restore_system_image_data at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:4219
jl_load_sysimg_so at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:663 [inlined]
ijl_restore_system_image at /cache/build/tester-amdci5-9/julialang/julia-master/src/staticdata.c:4190
_finish_julia_init at /cache/build/tester-amdci5-9/julialang/julia-master/src/init.c:884
julia_init at /cache/build/tester-amdci5-9/julialang/julia-master/src/init.c:864
static_init at /tmp/jl_lCDPQt/init.c:5
__libc_csu_init at ./try (unknown line)
__libc_start_main at /lib64/libc.so.6 (unknown line)
_start at ./try (unknown line)
Allocations: 0 (Pool: 0; Big: 0); GC: 0
Segmentation fault (core dumped)

Interestingly, if I compile without --trim --experimental I still get the warning, but I do not get the segmentation faults anymore.
Does anyone have an idea on how to solve this?

1 Like

Welcome! I highly suspect this is a recent regression in the nightlies — two new experimental features are colliding here. I would wager that trimming doesn’t know about binding partitions yet.

This is worth submitting as an issue on GitHub — I haven’t seen it reported yet.

In the meantime, you could try a slightly older nightly; I happen to have one that’s 54 days old and works as you expected.

4 Likes