Bug #3213

ConditionVariable#wait in main thread silently returns when a signal is received

Added by sylvain.joyeux (Sylvain Joyeux) almost 10 years ago. Updated almost 9 years ago.

ruby -v:
ruby 1.9.1p376 (2009-12-07 revision 26041) [x86_64-linux]


The signal handling implementation unconditionally sets the main thread state to RUNNING and interrupts it (thread.c: 2574). In practice, it means that if the main thread waits for a condition variable, it will resume its execution even though the variable has never been signaled.

(moreover, because of #3212, the CV becomes inconsistent and the thread will get interrupted next time the CV is signalled, even though it is not waiting for the CV).

IMO, a proper signal handling structure would be to wake up the thread only in interruption cases (i.e. when an exception such as Interrupt needs to be raised), but not when a trap is executed.

Though, I do think that condition variables should not silently be released when a signal is received. Worst case, an exception should be raised.

I set the priority to high as this bugs makes condition variables unreliable in practice


Updated by mame (Yusuke Endoh) almost 10 years ago

  • Status changed from Open to Rejected


This is a spec. Use ConditionVariable#wait in while loop.
See #3212 in detail.

Yusuke Endoh

Also available in: Atom PDF