From c1d78a7f0ece2004822193a0c1f1fd3dc38c2fdf Mon Sep 17 00:00:00 2001 From: Neeraj Bhunwal Date: Tue, 16 Apr 2019 09:33:08 +0530 Subject: [PATCH] do_mutex_lock: release mutex before checking for interrupts (fixes issue 15360) --- thread_sync.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/thread_sync.c b/thread_sync.c index 2123458127..c2612c1415 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -282,14 +282,18 @@ do_mutex_lock(VALUE self, int interruptible_p) th->status = prev_status; } th->vm->sleeper--; - if (mutex->th == th) mutex_locked(th, self); if (interruptible_p) { + /* release mutex before checking for interrupts...as interrupt checking + * code might call rb_raise() */ + if (mutex->th == th) mutex->th = 0; RUBY_VM_CHECK_INTS_BLOCKING(th->ec); /* may release mutex */ if (!mutex->th) { mutex->th = th; mutex_locked(th, self); } + } else { + if (mutex->th == th) mutex_locked(th, self); } } }