This doesn’t seem like the right place to post this error but none of the other topic areas seemed quite right either. If this is the wrong place please let me know where this should go.
A segmentation fault is occurring in my ray tracer at random points in the execution. It looks like the segmentation fault is occurring in the Julia garbage collector. The error always happens in a garbage collector function called gc_try_setmark.
Unfortunately it’s very difficult to include a minimum working example. The ray tracer is several thousand lines of code. Tracking the cause down is hard because the error occurs randomly, typically after tracing many billions of rays.
Sometimes the program will run to completion and render the entire image and sometimes it will die after rendering just a few hundred scanlines. This is strange because my code does not have a random component. It follows exactly the same execution path each time.
Not doing any pointer arithmetic, no @inbounds annotations on loops, no calls to c code or anything else low level. Just straight Julia code.
All the packages the code uses have been updated in the package manager.
My machine has 128GB RAM and the memory usage never rises much above 5 GB while the program is running so it’s unlikely to be an out of memory error.
This is the output of versioninfo():
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD EPYC 7702P 64-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, znver1)
Environment:
JULIA_NUM_THREADS = 64
JULIA_EDITOR = “/usr/share/code/code”
This is the stacktrace:
signal (11): Segmentation fault
in expression starting at /home/brian/repos/gitrepo/Julia/Optics/src/Optics.jl:30
gc_try_setmark at /buildworker/worker/package_linux64/build/src/gc.c:1642 [inlined]
gc_mark_scan_obj8 at /buildworker/worker/package_linux64/build/src/gc.c:1836 [inlined]
gc_mark_loop at /buildworker/worker/package_linux64/build/src/gc.c:2117
_jl_gc_collect at /buildworker/worker/package_linux64/build/src/gc.c:2899
jl_gc_collect at /buildworker/worker/package_linux64/build/src/gc.c:3105
maybe_collect at /buildworker/worker/package_linux64/build/src/gc.c:827 [inlined]
jl_gc_pool_alloc at /buildworker/worker/package_linux64/build/src/gc.c:1142
jl_gc_alloc_ at /buildworker/worker/package_linux64/build/src/julia_internal.h:246 [inlined]
jl_gc_alloc at /buildworker/worker/package_linux64/build/src/gc.c:3147
jl_alloc_svec_uninit at /buildworker/worker/package_linux64/build/src/simplevector.c:60
jl_alloc_svec at /buildworker/worker/package_linux64/build/src/simplevector.c:69
save_env at /buildworker/worker/package_linux64/build/src/subtype.c:149
forall_exists_subtype at /buildworker/worker/package_linux64/build/src/subtype.c:1447
forall_exists_equal at /buildworker/worker/package_linux64/build/src/subtype.c:1392
subtype at /buildworker/worker/package_linux64/build/src/subtype.c:1336
with_tvar at /buildworker/worker/package_linux64/build/src/subtype.c:702
subtype_unionall at /buildworker/worker/package_linux64/build/src/subtype.c:841 [inlined]
subtype at /buildworker/worker/package_linux64/build/src/subtype.c:1281
with_tvar at /buildworker/worker/package_linux64/build/src/subtype.c:702
subtype_unionall at /buildworker/worker/package_linux64/build/src/subtype.c:841 [inlined]
subtype at /buildworker/worker/package_linux64/build/src/subtype.c:1281
exists_subtype at /buildworker/worker/package_linux64/build/src/subtype.c:1425 [inlined]
forall_exists_subtype at /buildworker/worker/package_linux64/build/src/subtype.c:1453
jl_subtype_env at /buildworker/worker/package_linux64/build/src/subtype.c:1818
jl_isa at /buildworker/worker/package_linux64/build/src/subtype.c:2056
jl_new_structv at /buildworker/worker/package_linux64/build/src/datatype.c:928
Intersection at /home/brian/repos/gitrepo/Julia/Optics/src/Interval.jl:21
surfaceintersections at /home/brian/repos/gitrepo/Julia/Optics/src/BezierIntersection.jl:237
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:96
unknown function (ip: 0x7faa90095362)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2144 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2322
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:83
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:87
evalcsg at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:87
surfaceintersection at /home/brian/repos/gitrepo/Julia/Optics/src/CSG.jl:110
unknown function (ip: 0x7faa9008a762)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2144 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2322
render at /home/brian/repos/gitrepo/Julia/Optics/src/Visualization.jl:299
testrender at /home/brian/repos/gitrepo/Julia/Optics/src/Test.jl:981
unknown function (ip: 0x7faa9006e08b)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2158 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2322
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1692 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:369
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:458
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:409 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:817
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:911
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:814
jl_eval_module_expr at /buildworker/worker/package_linux64/build/src/toplevel.c:181
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:640
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:872
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:872
include at ./Base.jl:377
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2144 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2322
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1692 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:369
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:458
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:409 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:817
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:744
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:911
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:814
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:843
eval at ./boot.jl:331 [inlined]
eval at ./client.jl:449
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2144 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2322
top-level scope at ./none:3
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:808
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:764
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:843
eval at ./boot.jl:331
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2144 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2322
exec_options at ./client.jl:264
_start at ./client.jl:484
jfptr__start_2076.clone_1 at /home/brian/Applications/julia-1.4.0/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2144 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2322
jl_apply at /buildworker/worker/package_linux64/build/ui/../src/julia.h:1692 [inlined]
true_main at /buildworker/worker/package_linux64/build/ui/repl.c:96
main at /buildworker/worker/package_linux64/build/ui/repl.c:217
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /home/brian/Applications/julia-1.4.0/bin/julia (unknown line)
Allocations: 4054878845 (Pool: 4054859939; Big: 18906); GC: 2626
ERROR: Failed to precompile Optics [24114763-4efb-45e7-af0e-cde916beb153] to /home/brian/.julia/compiled/v1.4/Optics/60XLU_5Fisl.ji.
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
[3] _require(::Base.PkgId) at ./loading.jl:1029
[4] require(::Base.PkgId) at ./loading.jl:927
[5] require(::Module, ::Symbol) at ./loading.jl:922
[6] eval(::Module, ::Any) at ./boot.jl:331
[7] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
[8] run_backend(::REPL.REPLBackend) at /home/brian/.julia/packages/Revise/Pcs5V/src/Revise.jl:1073
[9] top-level scope at none:0