After #89, init is called during CameraList. We call CameraList multiple times. Therefore, we are overwriting the spinsys global, leaving the old value up for the GC, which will finalize it while we are using the Camera and cause a crash.
Simplest MWE:
julia> using Spinnaker
julia> CameraList()
CameraList with 1 enumerated devices:
ID Serial No. Description
0 20314192 FLIR Blackfly S BFS-U3-31S4M-BD
julia> CameraList()
CameraList with 1 enumerated devices:
ID Serial No. Description
0 20314192 FLIR Blackfly S BFS-U3-31S4M-BD
julia> GC.gc(true)
terminate called after throwing an instance of 'Spinnaker::Exception'
what(): Spinnaker: Can't clear a camera because something still holds a reference to the camera [-1004]
[9566] signal (6.-6): Aborted
in expression starting at REPL[3]:1
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
__verbose_terminate_handler at /workspace/srcdir/gcc-12.1.0/libstdc++-v3/libsupc++/vterminate.cc:95
__terminate at /workspace/srcdir/gcc-12.1.0/libstdc++-v3/libsupc++/eh_terminate.cc:48
__cxa_call_terminate at /workspace/srcdir/gcc-12.1.0/libstdc++-v3/libsupc++/eh_call.cc:54
__gxx_personality_v0 at /workspace/srcdir/gcc-12.1.0/libstdc++-v3/libsupc++/eh_personality.cc:688
_Unwind_RaiseException_Phase2 at /workspace/srcdir/gcc-12.1.0/libgcc/unwind.inc:64
_Unwind_Resume at /workspace/srcdir/gcc-12.1.0/libgcc/unwind.inc:242
unknown function (ip: 0x7faa6c0190f1)
_ZN9Spinnaker6SystemD1Ev at /opt/spinnaker/lib/libSpinnaker.so.2 (unknown line)
_ZN9Spinnaker6SystemD0Ev at /opt/spinnaker/lib/libSpinnaker.so.2 (unknown line)
spinSystemReleaseInstance at /opt/spinnaker/lib/libSpinnaker_C.so (unknown line)
spinSystemReleaseInstance at /home/ubuntu/.julia/packages/Spinnaker/cgNVi/src/wrapper/spin_api.jl:101 [inlined]
_release! at /home/ubuntu/.julia/packages/Spinnaker/cgNVi/src/System.jl:29
jfptr__releaseNOT._155490 at /home/pointcheck/.leuko/sysimages/LeukoCapture-x86_64-julia_v1.9.2-v2.16.2.so (unknown line)
_jl_invoke at /cache/build/default-amdci5-2/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci5-2/julialang/julia-release-1-dot-9/src/gf.c:2940
run_finalizer at /cache/build/default-amdci5-2/julialang/julia-release-1-dot-9/src/gc.c:417
jl_gc_run_finalizers_in_list at /cache/build/default-amdci5-2/julialang/julia-release-1-dot-9/src/gc.c:507
run_finalizers at /cache/build/default-amdci5-2/julialang/julia-release-1-dot-9/src/gc.c:553
run_finalizers at /cache/build/default-amdci5-2/julialang/julia-release-1-dot-9/src/gc.c:534 [inlined]
ijl_gc_collect at /cache/build/default-amdci5-2/julialang/julia-release-1-dot-9/src/gc.c:3725
gc at ./gcutils.jl:98
We have seen a number of crashes due to a regression from #89
The first thing to understand is that this line does not set the global to
true
: https://github.com/samuelpowell/Spinnaker.jl/blob/f3dcbe5f10c6e55a23a49d3b5f6daf63803dd960/src/Spinnaker.jl#L114 It instead declares a new local. This means that the global is alwaysfalse
and so ifinit
is called multiple times, then multipleSystem
objects are created.After #89,
init
is called duringCameraList
. We callCameraList
multiple times. Therefore, we are overwriting thespinsys
global, leaving the old value up for the GC, which will finalize it while we are using the Camera and cause a crash.Simplest MWE: