From d7ad53f249de459190d88bcb16c819411226be46 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 6 May 2025 19:08:02 -0700 Subject: [PATCH] Acquire VM lock around fork Otherwise it might be held by another Ractor, causing a deadlock in the new process. --- process.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/process.c b/process.c index 3aea80495d..605821853e 100644 --- a/process.c +++ b/process.c @@ -4132,8 +4132,12 @@ rb_fork_ruby(int *status) rb_thread_acquire_fork_lock(); disable_child_handler_before_fork(&old); - child.pid = pid = rb_fork(); - child.error = err = errno; + RB_VM_LOCK_ENTER(); + { + child.pid = pid = rb_fork(); + child.error = err = errno; + } + RB_VM_LOCK_LEAVE(); disable_child_handler_fork_parent(&old); /* yes, bad name */ if (