There's no guarantee that the problem that valgrind is reporting is the cause 
of your bug of course.

Anyhow, the code in question looks to be this, in threadpool.nim:
    
    
    proc nimSpawn3(fn: WorkerProc; data: pointer) {.compilerProc.} =
      # implementation of 'spawn' that is used by the code generator.
      while true:
        if selectWorker(readyWorker, fn, data): return
    

vs this:
    
    
    proc slave(w: ptr Worker) {.thread.} =
      isSlave = true
      while true:
        when declared(atomicStoreN):
          atomicStoreN(addr(w.ready), true, ATOMIC_SEQ_CST)
        else:
          w.ready = true
        readyWorker = w
    

Reply via email to