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

ruby-changes:52786

From: nagachika <ko1@a...>
Date: Thu, 11 Oct 2018 23:40:09 +0900 (JST)
Subject: [ruby-changes:52786] nagachika:r64998 (ruby_2_5): merge revision(s) 63711, 64398: [Backport #14841]

nagachika	2018-10-11 23:40:04 +0900 (Thu, 11 Oct 2018)

  New Revision: 64998

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

  Log:
    merge revision(s) 63711,64398: [Backport #14841]
    
    thread_sync.c (rb_mutex_lock): fix deadlock
    
    * thread_sync.c (rb_mutex_lock): fix deadlock
      [ruby-core:87467] [Bug #14841]
    
    thread_sync.c (rb_mutex_lock): acquire lock before being killed
    
    We (the thread acquiring the mutex) need to acquire the mutex
    before being killed to work with ConditionVariable#wait.
    
    Thus we reinstate the acquire-immediately-after-sleeping logic
    from pre-r63711 while still retaining the
    acquire-after-checking-for-interrupts logic from r63711.
    
    This regression was introduced in
    commit 501069b8a4013f2e3fdde35c50e9527ef0061963 (r63711)
    ("thread_sync.c (rb_mutex_lock): fix deadlock") for
    [Bug #14841]
    
    [ruby-core:88503] [Bug #14999] [Bug #14841]

  Modified directories:
    branches/ruby_2_5/
  Modified files:
    branches/ruby_2_5/thread_sync.c
    branches/ruby_2_5/version.h
Index: ruby_2_5/thread_sync.c
===================================================================
--- ruby_2_5/thread_sync.c	(revision 64997)
+++ ruby_2_5/thread_sync.c	(revision 64998)
@@ -272,6 +272,7 @@ rb_mutex_lock(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_5/thread_sync.c#L272
 	    list_add_tail(&mutex->waitq, &w.node);
 	    native_sleep(th, timeout); /* release GVL */
 	    list_del(&w.node);
+
 	    if (!mutex->th) {
 		mutex->th = th;
 	    }
@@ -287,10 +288,13 @@ rb_mutex_lock(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_5/thread_sync.c#L288
 		th->status = prev_status;
 	    }
 	    th->vm->sleeper--;
-
 	    if (mutex->th == th) mutex_locked(th, self);
 
-	    RUBY_VM_CHECK_INTS_BLOCKING(th->ec);
+	    RUBY_VM_CHECK_INTS_BLOCKING(th->ec); /* may release mutex */
+	    if (!mutex->th) {
+		mutex->th = th;
+	        mutex_locked(th, self);
+	    }
 	}
     }
     return self;
Index: ruby_2_5/version.h
===================================================================
--- ruby_2_5/version.h	(revision 64997)
+++ ruby_2_5/version.h	(revision 64998)
@@ -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 98
+#define RUBY_PATCHLEVEL 99
 
 #define RUBY_RELEASE_YEAR 2018
 #define RUBY_RELEASE_MONTH 10
Index: ruby_2_5
===================================================================
--- ruby_2_5	(revision 64997)
+++ ruby_2_5	(revision 64998)

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

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

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