Project

General

Profile

Bug #15310

[PATCH] thread_pthread.c: close race from UBF_TIMER and non-GVL-releasing thread

Added by normalperson (Eric Wong) about 1 year ago. Updated about 1 year ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:89827]

Description

thread_pthread.c: close race from UBF_TIMER and non-GVL-releasing thread

A Ruby thread may run without releasing the GVL if there is no
contention. And there may be no contention because another
thread missed its wakeup and needs to rely on ubf_list for
wakeups. So we need to ensure the Ruby thread can relinquish
GVL and trigger ubf_list wakeups to target thread when the POSIX
timer fires.

Thus, we trigger a timeslice on SIGVTALRM when triggered by
UBF_TIMER (we do not want excessive switching overhead on every
SIGVTALRM signal, either).

Note: I'm pretty sure this is necessary, correct and would introduce no
portability problems or performance overhead if I'm wrong...
I could definitely use an extra set of eyes on this, though.


Files

History

Updated by larskanis (Lars Kanis) about 1 year ago

Do you have an exploit to trigger the described issue?

Updated by normalperson (Eric Wong) about 1 year ago

lars@greiz-reinsdorf.de wrote:

Do you have an exploit to trigger the described issue?

Not yet, was just thinking about it again, now, though...

https://bugs.ruby-lang.org/issues/15310#change-74957

Updated by MSP-Greg (Greg L) about 1 year ago

normalperson (Eric Wong) Eric,

would introduce no portability problems or performance overhead if I'm wrong...
I could definitely use an extra set of eyes on this, though.

No idea about performance, but MinGW built & tested fine.
ruby 2.6.0dev (2018-11-20 trunk 65818) [x64-mingw32]

Also available in: Atom PDF