Project

General

Profile

Actions

Bug #15310

open

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

Added by normalperson (Eric Wong) about 6 years ago. Updated about 6 years ago.

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

Updated by larskanis (Lars Kanis) about 6 years ago

Do you have an exploit to trigger the described issue?

Updated by normalperson (Eric Wong) about 6 years ago

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 6 years 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]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0