Random crashes with Julia 1.7

I have an application (GitHub - ufechner7/KiteViewer: 3D viewer and simulator for airborne wind energy systems), which works fine with Julia 1.6.5, but sometimes crashes when using Julia 1.7.0 or 1.7.1. When I click on the “PLAY” button I get crash reports like:

ufechner@TUD277255:~/repos/KiteViewer$ ./kiteviewer.sh 
Lauching KiteViewer...

signal (11): Segmentation fault
in expression starting at none:1
gc_try_setmark at /buildworker/worker/package_linux64/build/src/gc.c:1711 [inlined]
gc_mark_loop at /buildworker/worker/package_linux64/build/src/gc.c:2303
_jl_gc_collect at /buildworker/worker/package_linux64/build/src/gc.c:3039
jl_gc_collect at /buildworker/worker/package_linux64/build/src/gc.c:3248
maybe_collect at /buildworker/worker/package_linux64/build/src/gc.c:882 [inlined]
jl_gc_pool_alloc at /buildworker/worker/package_linux64/build/src/gc.c:1209
iterate at ./compiler/ssair/ir.jl:472
ssa_substitute_op! at ./compiler/ssair/inlining.jl:1573
ssa_substitute! at ./compiler/ssair/inlining.jl:1528 [inlined]
ir_inline_item! at ./compiler/ssair/inlining.jl:373
batch_inline! at ./compiler/ssair/inlining.jl:594
ssa_inlining_pass! at ./compiler/ssair/inlining.jl:83
jfptr_ssa_inlining_passNOT._10068 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
run_passes at ./compiler/optimize.jl:307
optimize at ./compiler/optimize.jl:296 [inlined]
_typeinf at ./compiler/typeinfer.jl:255
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_apply at ./compiler/abstractinterpretation.jl:987
abstract_call_known at ./compiler/abstractinterpretation.jl:1249
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_apply at ./compiler/abstractinterpretation.jl:987
abstract_call_known at ./compiler/abstractinterpretation.jl:1249
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_apply at ./compiler/abstractinterpretation.jl:987
abstract_call_known at ./compiler/abstractinterpretation.jl:1249
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_apply at ./compiler/abstractinterpretation.jl:987
abstract_call_known at ./compiler/abstractinterpretation.jl:1249
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_apply at ./compiler/abstractinterpretation.jl:987
abstract_call_known at ./compiler/abstractinterpretation.jl:1249
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_apply at ./compiler/abstractinterpretation.jl:987
abstract_call_known at ./compiler/abstractinterpretation.jl:1249
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_apply at ./compiler/abstractinterpretation.jl:987
abstract_call_known at ./compiler/abstractinterpretation.jl:1249
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_apply at ./compiler/abstractinterpretation.jl:987
abstract_call_known at ./compiler/abstractinterpretation.jl:1249
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_apply at ./compiler/abstractinterpretation.jl:987
abstract_call_known at ./compiler/abstractinterpretation.jl:1249
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_apply at ./compiler/abstractinterpretation.jl:987
abstract_call_known at ./compiler/abstractinterpretation.jl:1249
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
jfptr_abstract_call_known_15367 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
tojlinvoke15833 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
j_abstract_call_known_14256 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_ext at ./compiler/typeinfer.jl:909
typeinf_ext_toplevel at ./compiler/typeinfer.jl:942
typeinf_ext_toplevel at ./compiler/typeinfer.jl:938
jfptr_typeinf_ext_toplevel_10334 at /home/ufechner/repos/KiteViewer/MakieSys-1.7-main.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
jl_type_infer at /buildworker/worker/package_linux64/build/src/gf.c:295
jl_generate_fptr at /buildworker/worker/package_linux64/build/src/jitlayers.cpp:338
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1980
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:2246 [inlined]
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2239 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
macro expansion at /home/ufechner/repos/KiteViewer/src/KiteViewer.jl:416 [inlined]
#28 at ./task.jl:423
unknown function (ip: 0x7fa61968549f)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:877
Allocations: 44069341 (Pool: 44054814; Big: 14527); GC: 55
./kiteviewer.sh: line 13: 28337 Segmentation fault      (core dumped) julia --startup-file=no -t 1 -J MakieSys-${julia_major}-${branch}.so --optimize=2 --project -e "push!(LOAD_PATH,joinpath(pwd(),\"src\"));include(\"./src/KiteViewer.jl\");main(true)"

Any idea? Is this a bug in Julia or in one of the packages or in my code?

I added a print statement, now I get:

===> i: GC error (probable corruption) :
Allocations: 45568134 (Pool: 45553210; Big: 14924); GC: 58
Base.Dict{Symbol, Observables.Observable{T} where T}(slots=Array{UInt8, (64,)}[0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01], keys=Array{Symbol, (64,)}[
  :projectiontype,
  :rotation_center,
  :tilt_down_key,
  :keyboard_translationspeed,
  :circular_rotation,
  :keyboard_zoomspeed,
  :mouse_rotationspeed,
  :near,
  :update_rate,
  #<null>,
  #<null>,
  :backward_key,

Does GC error mean that its a bug in Julia?

No. It likely means that there is a bug in calling the library which causes memory corruption. The GC is usually the first to notice.

Any idea how to debug this issue? I mean, why is it working with Julia 1.6 and not with Julia 1.7?

What I know has happened sometimes before is for example missing GC.@preserve and a new Julia version is optimizing better and the variable gets garbage collected from under you. I am not saying this is the case here but it is one example.

OK, I found a workaround that fixes my problem, but I don’t understand why it works.

Old code:

log = load_log(7, logfile)

New code:

tmp = load_log(7, logfile)
for i in 1:length(tmp.syslog)
    dummy=tmp.syslog[i]
end
log = tmp

The variable log is storing a flight log file. You can think of it as an array of structs. The last of these structs was used to display the last 3D view. Now I load a new log file, so the old one needs to be replaced (and garbage collected) by the new one, but it shall not be garbage collected before the new one is completely loaded.

Anyway, I do not understand why accessing each element of the new log file and putting it in a dummy variable solves my problem.

You can see the complete code here: KiteViewer/KiteViewerPure.jl at main · ufechner7/KiteViewer · GitHub

The following code also works:

log = load_log(7, logfile)
dummy = log.syslog[1]

So just adding one line solves the issue. But I think this is a bug in Julia 1.7. I will create a ticket.