mofezilla / gmail.com wrote:
> https://bugs.ruby-lang.org/issues/14841

I think the problem is mutex->th may be altered by
RUBY_VM_CHECK_INTS_BLOCKING(th->ec), and we miss
a point where "mutex->th = 0;"

Can you test?
```
--- a/thread_sync.c
+++ b/thread_sync.c
@@ -272,6 +272,7 @@ rb_mutex_lock(VALUE self)
 	    list_add_tail(&mutex->waitq, &w.node);
 	    native_sleep(th, timeout); /* release GVL */
 	    list_del(&w.node);
+	    RUBY_VM_CHECK_INTS_BLOCKING(th->ec);
 	    if (!mutex->th) {
 		mutex->th = th;
 	    }
@@ -289,8 +290,6 @@ rb_mutex_lock(VALUE self)
 	    th->vm->sleeper--;
 
 	    if (mutex->th == th) mutex_locked(th, self);
-
-	    RUBY_VM_CHECK_INTS_BLOCKING(th->ec);
 	}
     }
     return self;
```

I think the bug existed in <2.4, but 2.5 made it easier-to-hit.

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