Thanks for the reply. I've made some progress. Compiling and running the same code multiple times doesn't always result in the same output. I now suspect it might be a "timing" thing; depending on how fast the program crashes, the stdout might be flushed, or not, to the terminal. Looks like I'll have find an alternative way to follow the code, or learn to debug Nim...
EDIT: OK, just checked the echo() doc, and it flushes stdout. I guess that makes memory/stack corruption the more likely suspect.