[ruby-core:89374] [Ruby trunk Bug#14939] [PATCH] cont.c (ec_switch): prevent delayed/missed trap interrupt race

From: nagachika00@...
Date: 2018-10-11 14:58:35 UTC
List: ruby-core #89374
Issue #14939 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: REQUIRED to 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: DONE

ruby_2_5 r64999 merged revision(s) 64062.

----------------------------------------
Bug #14939: [PATCH] cont.c (ec_switch): prevent delayed/missed trap interrupt race
https://bugs.ruby-lang.org/issues/14939#change-74415

* Author: normalperson (Eric Wong)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: DONE
----------------------------------------
ko1: I noticed this while working on timer-thread elimination/lazy-spawning.
However, it looks like a bug we introduced in 2.5 with `ec'.
Can you check this patch? Thanks.


cont.c (ec_switch): prevent delayed/missed trap interrupt race

timer-thread may set trap interrupt with rb_threadptr_check_signal
at any time independent of GVL.  This means timer-thread may set
the trap interrupt flag on the previous execution context; causing
the flag to be unnoticed until a future ec switch (or lost
completely if the ec is done).

Note: I avoid relying on th->interrupt_lock here and use
atomics because we won't be able to rely on it for proposed lazy
timer-thread [Misc #14937].

This regression affects Ruby 2.5 as it was introduced by moving
interrupt_flag to `ec' which is an unstable pointer.  Ruby <= 2.4
was unaffected because vm->main_thread->interrupt_flag never
changed.


---Files--------------------------------
0001-cont.c-ec_switch-prevent-delayed-missed-trap-interru.patch (1.54 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next