This fairly simple program will fail, and I cannot find my bug:
git clone https://github.com/pb-cdunn/nim-help.git
cd nim-help
make
# nim c -r t_raptor_db.nim
Run
(I am using the `devel` branch of **Nim** , but the problem happens on 0.20.2
also.)
Traceback (most recent call last)
t_raptor_db.nim(181) t_raptor_db
raptor_db.nim(271) get_length_cutoff
/raptor_db.nim(254) load_rdb
Nim/lib/system/assign.nim(111) genericAssign
Nim/lib/system/assign.nim(100) genericAssignAux
Nim/lib/system/assign.nim(24) genericAssignAux
Nim/lib/system/assign.nim(20) genericAssignAux
Nim/lib/system/assign.nim(54) genericAssignAux
Nim/lib/system/gc.nim(435) newObjNoInit
Nim/lib/system/gc.nim decRef
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Run
This is very discouraging. There is a GC deref problem with fairly simple code,
and I am completely unable to debug it myself. It crashes in different places
when I make very small changes, so it is clearly a memory bug. It _might_ be
from how I use `sscanf`, but I am clueless. I've added `echo` all over the
place, but I have no idea where the problem originates.
I hoped I could debug this by using `--newruntime` and **valgrind** , but I am
not able to build with newruntime.
raptor_db.nim(178, 38) Error: region needs to be an object type
Run
(That's on the `newruntime` branch.)
I would be very excited to see "newruntime" working, precisely to help me with
this sort of memory bug. But that's in the distant future.
If no-one can help me fix this, I might have to give up on Nim completely
within my company.