Skip to content

Commit 9fc4c79

Browse files
committed
merge revision(s) 64062: [Backport ruby#14939]
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 ruby#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. [ruby-core:88119] [Bug ruby#14939] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@64999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent c561f04 commit 9fc4c79

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

β€Žcont.cβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,17 @@ static inline void
240240
ec_switch(rb_thread_t *th, rb_fiber_t *fib)
241241
{
242242
rb_execution_context_t *ec = &fib->cont.saved_ec;
243+
243244
ruby_current_execution_context_ptr = th->ec = ec;
245+
246+
/*
247+
* timer-thread may set trap interrupt on previous th->ec at any time;
248+
* ensure we do not delay (or lose) the trap interrupt handling.
249+
*/
250+
if (th->vm->main_thread == th && rb_signal_buff_size() > 0) {
251+
RUBY_VM_SET_TRAP_INTERRUPT(ec);
252+
}
253+
244254
VM_ASSERT(ec->fiber_ptr->cont.self == 0 || ec->vm_stack != NULL);
245255
}
246256

β€Žversion.hβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.5.2"
22
#define RUBY_RELEASE_DATE "2018-10-11"
3-
#define RUBY_PATCHLEVEL 99
3+
#define RUBY_PATCHLEVEL 100
44

55
#define RUBY_RELEASE_YEAR 2018
66
#define RUBY_RELEASE_MONTH 10

0 commit comments

Comments
 (0)