Skip to content
  • Sergei Trofimovich's avatar
    fix EBADF unqueueing in select backend (Trac #10590) · 5857e0af
    Sergei Trofimovich authored and Ben Gamari's avatar Ben Gamari committed
    Alexander found a interesting case:
    1. We have a queue of two waiters in a blocked_queue
    2. first file descriptor changes state to RUNNABLE,
       second changes to INVALID
    3. awaitEvent function dequeued RUNNABLE thread to a
       run queue and attempted to dequeue INVALID descriptor
       to a run queue.
    
    Unqueueing INVALID fails thusly:
            #3  0x000000000045cf1c in barf (s=0x4c1cb0 "removeThreadFromDeQueue: not found")
                                   at rts/RtsMessages.c:42
            #4  0x000000000046848b in removeThreadFromDeQueue (...) at rts/Threads.c:249
            #5  0x000000000049a120 in removeFromQueues (...) at rts/RaiseAsync.c:719
            #6  0x0000000000499502 in throwToSingleThreaded__ (...) at rts/RaiseAsync.c:67
            #7  0x0000000000499555 in throwToSingleThreaded (..) at rts/RaiseAsync.c:75
            #8  0x000000000047c27d in awaitEvent (wait=rtsFalse) at rts/posix/Select.c:415
    
    The problem here is a throwToSingleThreaded function that tries
    t...
    5857e0af