Project

General

Profile

Bug #15798

Fix threads not waking up on SIGINT when using UBF_TIMER_PTHREAD

Added by jeremyevans0 (Jeremy Evans) 25 days ago. Updated 5 days ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.0dev (2019-04-26 trunk e804fcb42c) [x86_64-openbsd]
[ruby-core:92428]

Description

When using UBF_TIMER_PTHREAD, the timer_pthread_fn function will
not signal the main thread with SIGVTALRM in cases where
timer_pthread is armed before consume_communication_pipe is called.
This is because consume_communication_pipe will unarm the timer.

Fix this by checking the return value of consume_communication_pipe.
If it returns TRUE and the timer_pthread is disarmed, then signal
the main thread with SIGVTALRM.

This fixes TestThread#test_thread_timer_and_interrupt. It also
fixes the use of Ctrl+C/SIGINT in irb on OpenBSD, and I'm guessing
other platforms that use UBF_TIMER_PTHREAD. Previously,
you could hit Ctrl+C multiple times and it would do nothing until
another key was pressed (even Backspace).

If this is determined to be the correct fix, this should be
backported to 2.6, but it is not a problem in earlier versions.


Files

fix-pthread-timer.patch (2.43 KB) fix-pthread-timer.patch jeremyevans0 (Jeremy Evans), 04/26/2019 11:31 PM

History

Updated by jeremyevans0 (Jeremy Evans) 5 days ago

I've tested on Linux when forcing UBF_TIMER_PTHREAD. While the patch does not appear to be necessary on Linux, there are no regressions in the tests when using it, so it should be safe. It does fix the annoying current behavior on OpenBSD, so I hope a committer can review and commit it.

Also available in: Atom PDF