Traceback (most recent call last)
/home/stefan/pet2/pet.nim(717) pet
/home/stefan/pet2/pet.nim(714) test
/home/stefan/pet2/pet.nim(683) newDisplay
/home/stefan/.nimble/pkgs/gintro-#head/gintro/gio.nim(24220) run
/home/stefan/Nim/lib/core/macros.nim(570) connect_for_signal_cdecl_scroll_event4
/home/stefan/pet2/pet.nim(584) scrollEvent
/home/stefan/pet2/pet.nim(518) updateAdjustmentsAndPaint
/home/stefan/pet2/pet.nim(479) paint
/home/stefan/pet2/pet.nim(434) draw
/home/stefan/pet2/pet.nim(334) drawSelected
/home/stefan/.nimble/pkgs/gintro-#head/gintro/cairoimpl.nim(243) popGroup
/home/stefan/Nim/lib/system/gc.nim(440) newObj
/home/stefan/Nim/lib/system/alloc.nim(777) rawAlloc
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
I get this in a drawing app rarely. I assume that it is not really GC related but a bug in my own code, maybe the GTK/Cairo bindings. My code may damage some data structures of GC.
Solution seems to be easy: In
https://github.com/StefanSalewski/gintro/blob/master/gintro/cairoimpl.nim#L242
proc popGroup*(cr: Context): Pattern =
new(result, patternDestroy)
result.impl = cairo_pop_group(cr.impl)
discard cairo_pattern_set_user_data(result.impl, NUDK, cast[pointer](result), gcuref)
There is no GC_Ref() call, so gcuref may call GC_Unref() for Pattern object without a matching GC_Ref(). Indeed adding GC_Ref(result) seems to fix that crash, but I have not much tested yet.