import os var chan: Channel[string] proc ourThread() {.thread.} = sleep(100) chan.send "Hello" sleep(100) chan.send "World" sleep(100) chan.send "" chan.open proc doThread(): Thread[void] = createThread(result, ourThread) let t = doThread() while true: let msg = chan.recv if msg.len == 0: break echo msg chan.close echo "Thread completed" No stack traceback available SIGSEGV: Illegal storage access. (Attempt to read from nil?) # This was my error, now I understand how I got it