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

ORC/JLJIT: Segfault on master #496

Closed
maleadt opened this issue Dec 12, 2024 · 4 comments · Fixed by JuliaLang/julia#56854
Closed

ORC/JLJIT: Segfault on master #496

maleadt opened this issue Dec 12, 2024 · 4 comments · Fixed by JuliaLang/julia#56854

Comments

@maleadt
Copy link
Collaborator

maleadt commented Dec 12, 2024

MWE:

using LLVM

function main()
    @dispose jljit=JuliaOJIT() begin
        jd = JITDylib(jljit)

        fn = "SomeFunction"
        obj = @dispose ctx=Context() mod=LLVM.Module("jit") begin
            ft = LLVM.FunctionType(LLVM.VoidType())
            fun = LLVM.Function(mod, fn, ft)

            @dispose builder=IRBuilder() begin
                entry = BasicBlock(fun, "entry")
                position!(builder, entry)
                ret!(builder)
            end
            verify(mod)

            @dispose tm=JITTargetMachine() begin
                emit(tm, mod, LLVM.API.LLVMObjectFile)
            end
        end
        add!(jljit, jd, MemoryBuffer(obj))
        lookup(jljit, fn)
        empty!(jd)
    end
end

isinteractive() || main()
[460761] signal 11 (1): Segmentation fault
in expression starting at /home/tim/Julia/pkg/LLVM/wip.jl:30
deregisterEHFrames at /cache/build/builder-demeter6-4/julialang/julia-master/src/jitlayers.cpp:1274
_ZN4llvm3orc24RTDyldObjectLinkingLayer21handleRemoveResourcesERNS0_8JITDylibEm at /home/tim/Julia/depot/juliaup/julia-nightly/bin/../lib/julia/libLLVM.so.18.1jl (unknown line)
_ZN4llvm3orc16ExecutionSession21removeResourceTrackerERNS0_15ResourceTrackerE at /home/tim/Julia/depot/juliaup/julia-nightly/bin/../lib/julia/libLLVM.so.18.1jl (unknown line)
_ZN4llvm3orc8JITDylib5clearEv at /home/tim/Julia/depot/juliaup/julia-nightly/bin/../lib/julia/libLLVM.so.18.1jl (unknown line)
LLVMOrcJITDylibClear at /home/tim/Julia/depot/juliaup/julia-nightly/bin/../lib/julia/libLLVM.so.18.1jl (unknown line)
LLVMOrcJITDylibClear at /home/tim/Julia/pkg/LLVM/lib/18/libLLVM.jl:10213 [inlined]
empty! at /home/tim/Julia/pkg/LLVM/src/orc.jl:211 [inlined]
macro expansion at /home/tim/Julia/pkg/LLVM/wip.jl:26 [inlined]
macro expansion at /home/tim/Julia/pkg/LLVM/src/base.jl:97 [inlined]
main at /home/tim/Julia/pkg/LLVM/wip.jl:5
unknown function (ip: 0x7af4ad300abe) at (unknown file)
jl_apply at /cache/build/builder-demeter6-4/julialang/julia-master/src/julia.h:2233 [inlined]
do_call at /cache/build/builder-demeter6-4/julialang/julia-master/src/interpreter.c:125
eval_value at /cache/build/builder-demeter6-4/julialang/julia-master/src/interpreter.c:243
eval_stmt_value at /cache/build/builder-demeter6-4/julialang/julia-master/src/interpreter.c:194 [inlined]
eval_body at /cache/build/builder-demeter6-4/julialang/julia-master/src/interpreter.c:691
jl_interpret_toplevel_thunk at /cache/build/builder-demeter6-4/julialang/julia-master/src/interpreter.c:896
jl_toplevel_eval_flex at /cache/build/builder-demeter6-4/julialang/julia-master/src/toplevel.c:1070
jl_toplevel_eval_flex at /cache/build/builder-demeter6-4/julialang/julia-master/src/toplevel.c:1010
ijl_toplevel_eval at /cache/build/builder-demeter6-4/julialang/julia-master/src/toplevel.c:1082
ijl_toplevel_eval_in at /cache/build/builder-demeter6-4/julialang/julia-master/src/toplevel.c:1127
eval at ./boot.jl:479
include_string at ./loading.jl:2846
_include at ./loading.jl:2906
include at ./Base.jl:300
exec_options at ./client.jl:329
_start at ./client.jl:558
jfptr__start_108480.1 at /home/tim/Julia/depot/juliaup/julia-nightly/lib/julia/sys.so (unknown line)
jl_apply at /cache/build/builder-demeter6-4/julialang/julia-master/src/julia.h:2233 [inlined]
true_main at /cache/build/builder-demeter6-4/julialang/julia-master/src/jlapi.c:922
jl_repl_entrypoint at /cache/build/builder-demeter6-4/julialang/julia-master/src/jlapi.c:1081
main at /cache/build/builder-demeter6-4/julialang/julia-master/cli/loader_exe.c:58
unknown function (ip: 0x7af4c8110e07) at /usr/lib/libc.so.6
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
unknown function (ip: 0x4010b8) at /workspace/srcdir/glibc-2.17/csu/../sysdeps/x86_64/start.S
Allocations: 3272445 (Pool: 3272359; Big: 86); GC: 4
@maleadt
Copy link
Collaborator Author

maleadt commented Dec 12, 2024

Bisected to JuliaLang/julia#56179 (presumably something in JuliaLang/julia@f0ab810).

@vtjnash Any quick thoughts as to why LLVMOrcJITDylibClear would crash now?

@vtjnash
Copy link

vtjnash commented Dec 12, 2024

The ForwardingMemoryManager destroys its internal reference after the call to finalizeMemory

@maleadt
Copy link
Collaborator Author

maleadt commented Dec 16, 2024

Implying that's a bug with ForwardingMemoryManager, or what are you saying? AFAICT it should be allowed to call JITDylib::clear here.

@vtjnash
Copy link

vtjnash commented Dec 17, 2024

We've never supported clear before, but usually stubbed it to a no-op, which I guess could be restored as the behavior here (e.g. delete the code that is crashing)

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

Successfully merging a pull request may close this issue.

2 participants