I have written some code that adds new functionalities to a Julia library that wraps a C library. The code executes fine, in that it generates outcomes as expected, but on exit of Julia it leads to a segmentation fault with the following message (on OS X):
signal (11): Segmentation fault: 11
in expression starting at no file:0
_ZN4llvm16MetadataTracking7untrackEPvRNS_8MetadataE at /Applications/Julia-1.0.app/Contents/Resources/julia/lib/julia/libLLVM.dylib (unknown line)
_ZN4llvm6MDNode17dropAllReferencesEv at /Applications/Julia-1.0.app/Contents/Resources/julia/lib/julia/libLLVM.dylib (unknown line)
_ZN4llvm15LLVMContextImplD2Ev at /Applications/Julia-1.0.app/Contents/Resources/julia/lib/julia/libLLVM.dylib (unknown line)
_ZN4llvm11LLVMContextD1Ev at /Applications/Julia-1.0.app/Contents/Resources/julia/lib/julia/libLLVM.dylib (unknown line)
__cxa_finalize_ranges at /usr/lib/system/libsystem_c.dylib (unknown line)
exit at /usr/lib/system/libsystem_c.dylib (unknown line)
jl_exit at /Users/osx/buildbot/slave/package_osx64/build/src/jl_uv.c:605
exit at ./initdefs.jl:28 [inlined]
exit at ./initdefs.jl:29
do_call at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:324
eval_stmt_value at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:363 [inlined]
eval_body at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:682
jl_interpret_toplevel_thunk_callback at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:806
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x11a11f07f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:815
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:805
jl_toplevel_eval_in at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:622
eval at ./boot.jl:319
eval_user_input at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:85
macro expansion at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:117 [inlined]
#28 at ./task.jl:259
jl_apply at /Users/osx/buildbot/slave/package_osx64/build/src/./julia.h:1537 [inlined]
start_task at /Users/osx/buildbot/slave/package_osx64/build/src/task.c:268
Allocations: 29249313 (Pool: 29243444; Big: 5869); GC: 54
Segmentation fault: 11
I would appreciate any guess about the cause of the segfault or any general suggestion about what kind of operation done in the code I should look at.
How to reproduce:
-
Check out this PR.
-
Go to the
LRSLib.jl/test
directory. -
Run either
using LRSLib LRSLib.nashsolve("game1", "game2") exit()
or
using LRSLib, Test include("nash.jl") exit()
(Segfault does not always occur, so one may have to repeat several times.)
Here’s lldb’s output, in case it is helpful.
Segfault occurs both on 1.0.3 and 1.1.0.
julia> versioninfo()
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)
julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, ivybridge)