Open
Description
opened on Nov 19, 2024
The following module compiles and runs fine with juliac on Ubuntu 22.04.5
module JuliacTest
import Base.@ccallable
function foo()::Cint
Cint(1)
end
@ccallable function main()::Cint
println(Core.stdout, "I'm alive and well")
u = foo()
println(Core.stdout, u)
Cint(0)
end
end
shell> /tmp/foo
I'm alive and well
1
but if the function foo
is marked as @ccallable
, compilation finishes without errors but the binary segfaults with the error below.
I compiled using
julia +nightly --experimental /home/fredrikb/repos/julia/contrib/juliac.jl --output-exe /tmp/foo --trim=unsafe-warn /tmp/juliac_test.jl
and the patch from https://github.com/JuliaLang/julia/pull/56602/files
shell> /tmp/foo
[222011] signal 11 (1): Segmentation fault
in expression starting at none:0
jl_symbol_name_ at /cache/build/builder-demeter6-0/julialang/julia-master/src/julia.h:1427 [inlined]
jl_generate_ccallable at /cache/build/builder-demeter6-0/julialang/julia-master/src/codegen.cpp:8002
jl_compile_extern_c_impl at /cache/build/builder-demeter6-0/julialang/julia-master/src/jitlayers.cpp:746
jl_compile_extern at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:2429 [inlined]
jl_reinit_ccallable at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:2441 [inlined]
jl_restore_system_image_from_stream_ at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:3929
jl_restore_system_image_from_stream at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:4088 [inlined]
ijl_restore_system_image_data at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:4153
jl_load_sysimg_so at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:659 [inlined]
ijl_restore_system_image at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:4124
_finish_julia_init at /cache/build/builder-demeter6-0/julialang/julia-master/src/init.c:862
julia_init at /cache/build/builder-demeter6-0/julialang/julia-master/src/init.c:842
static_init at /tmp/jl_OcwliW/init.c:5
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /tmp/foo (unknown line)
Allocations: 0 (Pool: 0; Big: 0); GC: 0
[222011] signal 11 (1): Segmentation fault
in expression starting at none:0
jl_symbol_name_ at /cache/build/builder-demeter6-0/julialang/julia-master/src/julia.h:1427 [inlined]
jl_generate_ccallable at /cache/build/builder-demeter6-0/julialang/julia-master/src/codegen.cpp:8002
jl_compile_extern_c_impl at /cache/build/builder-demeter6-0/julialang/julia-master/src/jitlayers.cpp:746
jl_compile_extern at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:2429 [inlined]
jl_reinit_ccallable at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:2441 [inlined]
jl_restore_system_image_from_stream_ at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:3929
jl_restore_system_image_from_stream at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:4088 [inlined]
ijl_restore_system_image_data at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:4153
jl_load_sysimg_so at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:659 [inlined]
ijl_restore_system_image at /cache/build/builder-demeter6-0/julialang/julia-master/src/staticdata.c:4124
_finish_julia_init at /cache/build/builder-demeter6-0/julialang/julia-master/src/init.c:862
julia_init at /cache/build/builder-demeter6-0/julialang/julia-master/src/init.c:842
static_init at /tmp/jl_OcwliW/init.c:5
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /tmp/foo (unknown line)
Allocations: 0 (Pool: 0; Big: 0); GC: 0
/bin/bash: line 1: 222011 Segmentation fault (core dumped) ( /tmp/foo )
Activity