[前][次][番号順一覧][スレッド一覧]

ruby-changes:52787

From: nagachika <ko1@a...>
Date: Thu, 11 Oct 2018 23:58:36 +0900 (JST)
Subject: [ruby-changes:52787] nagachika:r64999 (ruby_2_5): merge revision(s) 64062: [Backport #14939]

nagachika	2018-10-11 23:58:30 +0900 (Thu, 11 Oct 2018)

  New Revision: 64999

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64999

  Log:
    merge revision(s) 64062: [Backport #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 #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 #14939]

  Modified directories:
    branches/ruby_2_5/
  Modified files:
    branches/ruby_2_5/cont.c
    branches/ruby_2_5/version.h
Index: ruby_2_5/cont.c
===================================================================
--- ruby_2_5/cont.c	(revision 64998)
+++ ruby_2_5/cont.c	(revision 64999)
@@ -240,7 +240,17 @@ static inline void https://github.com/ruby/ruby/blob/trunk/ruby_2_5/cont.c#L240
 ec_switch(rb_thread_t *th, rb_fiber_t *fib)
 {
     rb_execution_context_t *ec = &fib->cont.saved_ec;
+
     ruby_current_execution_context_ptr = th->ec = ec;
+
+    /*
+     * timer-thread may set trap interrupt on previous th->ec at any time;
+     * ensure we do not delay (or lose) the trap interrupt handling.
+     */
+    if (th->vm->main_thread == th && rb_signal_buff_size() > 0) {
+        RUBY_VM_SET_TRAP_INTERRUPT(ec);
+    }
+
     VM_ASSERT(ec->fiber_ptr->cont.self == 0 || ec->vm_stack != NULL);
 }
 
Index: ruby_2_5/version.h
===================================================================
--- ruby_2_5/version.h	(revision 64998)
+++ ruby_2_5/version.h	(revision 64999)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1
 #define RUBY_VERSION "2.5.2"
 #define RUBY_RELEASE_DATE "2018-10-11"
-#define RUBY_PATCHLEVEL 99
+#define RUBY_PATCHLEVEL 100
 
 #define RUBY_RELEASE_YEAR 2018
 #define RUBY_RELEASE_MONTH 10
Index: ruby_2_5
===================================================================
--- ruby_2_5	(revision 64998)
+++ ruby_2_5	(revision 64999)

Property changes on: ruby_2_5
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r64062

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]