Both the main thread (1) and the worker thread (3) are in "nanosleep()". (The 
rest are in `pthread_cond_wait()`.) 
    
    
    (gdb) bt
    #0  0x00007f172734be4d in nanosleep () from /lib64/libpthread.so.0
    #1  0x000000000044655b in nossleep (milsecs=milsecs@entry=100) at 
/mnt/software/n/nim/0.20.2/Nim/lib/pure/os.nim:2791
    #2  0x000000000046f4f2 in sync_WTnSSeVs19cfp5pRs6KBLXQ_2 ()
        at 
/mnt/software/n/nim/0.20.2/Nim/lib/pure/concurrency/threadpool.nim:596
    
    (gdb) thread 3
    [Switching to thread 3 (Thread 0x7f17231cd700 (LWP 32423))]
    
    (gdb) bt
    #0  0x00007f172734be4d in nanosleep () from /lib64/libpthread.so.0
    #1  0x000000000044655b in nossleep (milsecs=milsecs@entry=100) at 
/mnt/software/n/nim/0.20.2/Nim/lib/pure/os.nim:2791
    #2  0x000000000046dead in slave_1yqYR9cLeffanOjn0piJ2VQ (w=<optimized out>)
        at 
/mnt/software/n/nim/0.20.2/Nim/lib/pure/concurrency/threadpool.nim:346
    #3  0x0000000000413144 in threadProcWrapDispatch_4bfnMli3YetX01hUbaU1ig_2 (
        thrd=0x79c040 <workers_bezHuru9a1bEti2XBmfodvA+704>) at 
/mnt/software/n/nim/0.20.2/Nim/lib/system/threads.nim:141
    #4  0x000000000041360a in threadProcWrapStackFrame_4bfnMli3YetX01hUbaU1ig (
        thrd=thrd@entry=0x79c040 <workers_bezHuru9a1bEti2XBmfodvA+704>)
        at /mnt/software/n/nim/0.20.2/Nim/lib/system/threads.nim:156
    #5  0x000000000041364d in threadProcWrapper_oTnP9cUoE9cVTUL7iHAoIIAA 
(closure=0x79c040 <workers_bezHuru9a1bEti2XBmfodvA+704>)
        at /mnt/software/n/nim/0.20.2/Nim/lib/system/threads.nim:165
    #6  0x00007f1727344e25 in start_thread () from /lib64/libpthread.so.0
    #7  0x00007f172707234d in clone () from /lib64/libc.so.6
    
    
    Run
    
    
    338 proc slave(w: ptr Worker) {.thread.} =
    339   isSlave = true
    340   while true:
    341     if w.shutdown:
    342       w.shutdown = false
    343       atomicDec currentPoolSize
    344       while true:
    345         if w.data != nil:  # <--
    346           sleep(threadpoolWaitMs)
    
    
    Run

That was added recently, in 
[https://github.com/nim-lang/Nim/issues/11275](https://github.com/nim-lang/Nim/issues/11275),
 to fix a threadpool seg-fault.

Reply via email to