From: normalperson@... Date: 2018-11-16T02:30:12+00:00 Subject: [ruby-core:89827] [Ruby trunk Bug#15310] [PATCH] thread_pthread.c: close race from UBF_TIMER and non-GVL-releasing thread Issue #15310 has been reported by normalperson (Eric Wong). ---------------------------------------- Bug #15310: [PATCH] thread_pthread.c: close race from UBF_TIMER and non-GVL-releasing thread https://bugs.ruby-lang.org/issues/15310 * Author: normalperson (Eric Wong) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- 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-------------------------------- 0001-thread_pthread.c-close-race-from-UBF_TIMER-and-non-G.patch (5.32 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: