Project

General

Profile

Bug #15798

Fix threads not waking up on SIGINT when using UBF_TIMER_PTHREAD

Added by jeremyevans0 (Jeremy Evans) about 1 year ago. Updated 10 months ago.

Status:
Closed
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

Updated by jeremyevans0 (Jeremy Evans) about 1 year 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.

#2

Updated by jeremyevans (Jeremy Evans) about 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|1ef39d8d099f145222b9352423af16a2bab6e05b.


Fix process not waking up on signals on OpenBSD

When using UBF_TIMER_PTHREAD (the UBF handler on OpenBSD), 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.

On OpenBSD, this fixes TestThread#test_thread_timer_and_interrupt, and
fixes hangs in TestProcess#test_execopts_redirect_open_fifo_interrupt_raise
and TestProcess#test_execopts_redirect_open_fifo_interrupt_print.
It also fixes the use of Ctrl+C/SIGINT in irb on OpenBSD. It does not
cause any test failures on Linux when UBF_TIMER_PTHREAD is forced as
the UBF handler.

Fixes [Bug #15798]

Updated by nagachika (Tomoyuki Chikanaga) 10 months ago

  • Backport changed from 2.4: DONTNEED, 2.5: DONTNEED, 2.6: REQUIRED to 2.4: DONTNEED, 2.5: DONTNEED, 2.6: DONE

ruby_2_6 r67725 merged revision(s) 1ef39d8d099f145222b9352423af16a2bab6e05b.

Also available in: Atom PDF