If you echo in a thread, you use Nim string. Nim strings are allocated with Nim GC which does not exist within an OpenMP context except for the master thread.
So either you don't allocate string, sequence or ref object or you initialize the GC in those threads with: <https://github.com/numforge/laser/blob/e23b5d6/laser/openmp.nim#L88-L110> template attachGC*(): untyped = ## If you are allocating reference types, sequences or strings ## in a parallel section, you need to attach and detach ## a GC for each thread. Those should be thread-local temporaries. ## ## This attaches the GC. ## ## Note: this creates too strange error messages ## when --threads is not on: https://github.com/nim-lang/Nim/issues/9489 if(omp_get_thread_num()!=0): setupForeignThreadGc() template detachGC*(): untyped = ## If you are allocating reference types, sequences or strings ## in a parallel section, you need to attach and detach ## a GC for each thread. Those should be thread-local temporaries. ## ## This detaches the GC. ## ## Note: this creates too strange error messages ## when --threads is not on: https://github.com/nim-lang/Nim/issues/9489 if(omp_get_thread_num()!=0): teardownForeignThreadGc() Run Alternatively use --gc:arc or --gc:orc
