diff --git a/thread_pthread.c b/thread_pthread.c index 4a240f4fbe1224..cae4a8e1bd4b66 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -593,8 +593,16 @@ thread_sched_setup_running_threads(struct rb_thread_sched *sched, rb_ractor_t *c if (add_th && !del_th && UNLIKELY(vm->ractor.sync.lock_owner != NULL)) { // it can be after barrier synchronization by another ractor - RB_VM_LOCK_ENTER(); - RB_VM_LOCK_LEAVE(); + rb_thread_t *lock_owner = NULL; +#if VM_CHECK_MODE + lock_owner = sched->lock_owner; +#endif + thread_sched_unlock(sched, lock_owner); + { + RB_VM_LOCK_ENTER(); + RB_VM_LOCK_LEAVE(); + } + thread_sched_lock(sched, lock_owner); } //RUBY_DEBUG_LOG("+:%u -:%u +ts:%u -ts:%u run:%u->%u",