diff --git a/thread_sync.c b/thread_sync.c index 8964e24a5f..f775d44451 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -289,14 +289,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); } } } diff --git a/version.h b/version.h index 3b5eea55ac..8b0acbbf3f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.5.6" #define RUBY_RELEASE_DATE "2019-08-27" -#define RUBY_PATCHLEVEL 182 +#define RUBY_PATCHLEVEL 183 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 8