My program does not do tricky system things, only using ref object to build a toroid matrix, letting the compiler initialize all the objects. It segfaults when building the matrix, without any stack trace. I've tried placing echo and debugEcho in calls to get how far in the code it runs, but apart from the first message before the first call, I don't get any hint where the problem is: no message printed. I've tried changing the garbage collector too without success. gdb shows the proc call. This behaviours happens with Nim 0.19 and 1.0.4. With version 1.0.0, I had an assert message about a seq length having changed in an iterator, but this message disappears when compiled with version 1.0.4.
Safe programs in Nim aren't supposed to end cleanly or abort with a stack trace, or at least a debug message?
(gdb) run
Starting program: /home/pierre/sdk/sdk3
Let's go to solve...
Program received signal SIGSEGV, Segmentation fault.
0x0000555555575264 in solve__1I5XRgZ0uR8B7KpdLW9aiTA (board=0x55555578d420 <board__q5FjO9cH9cCMNQvQpNT17vtQ>,
Result=0x55555578d780 <solution__wgH7GGNMiUZtSI9csVTrbxw>) at /home/pierre/sdk/sdk3.nim:323
323 proc solve(board: Board): Board =
(gdb) bt
#0 0x0000555555575264 in solve__1I5XRgZ0uR8B7KpdLW9aiTA (board=0x55555578d420 <board__q5FjO9cH9cCMNQvQpNT17vtQ>,
Result=0x55555578d780 <solution__wgH7GGNMiUZtSI9csVTrbxw>) at /home/pierre/sdk/sdk3.nim:323
#1 0x00005555555758d1 in NimMainModule () at /home/pierre/sdk/sdk3.nim:421
#2 0x0000555555575953 in NimMainInner () at /home/pierre/.choosenim/toolchains/nim-1.0.4/lib/system.nim:3630
#3 0x0000555555575e4f in NimMain () at /home/pierre/.choosenim/toolchains/nim-1.0.4/lib/system.nim:3638
#4 0x0000555555575e86 in main (argc=<optimized out>, args=<optimized out>, env=<optimized out>)
at /home/pierre/.choosenim/toolchains/nim-1.0.4/lib/system.nim:3645
(gdb) list
318 let c = ans1 mod SIZE
319 let num = chr((ans2 mod SIZE) + 1)
320 result[r][c] = num
321
322
323 proc solve(board: Board): Board =
324 debugEcho "Before convert"
325 let cover = convertInCoverMatrix(board)
326 debugEcho "new DLX"
327 var dlx = newDLX(cover)
Is there something I can try before creating a minimal example and opening a bug?
Is there something I can try before creating a minimal example and opening a bug?
Reduce the involved data structure sizes and see if the crash disappears. If so, you might simply put too much data onto the stack causing a crash.