Project

General

Profile

Actions

Bug #14939

closed

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

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

Status:
Closed
Target version:
-
[ruby-core:88110]

Description

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0