From e2f527641a6a585cf78c94e21c3002a59d8040d6 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 11 Jul 2022 12:40:34 -0700 Subject: [PATCH] Use VM Lock when mutating waiting threads list `rb_thread_wait_for_single_fd` needs to mutate the `waiting_fds` list that is stored on the VM. We need to delete the FD from the list before returning, and deleting from the list requires a VM lock (because the list is a global). [Bug #18816] [ruby-core:108771] Co-Authored-By: Alan Wu --- thread.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/thread.c b/thread.c index 5fd7a7f67ac..7d1a4ee3fb4 100644 --- a/thread.c +++ b/thread.c @@ -4342,7 +4342,11 @@ select_single_cleanup(VALUE ptr) { struct select_args *args = (struct select_args *)ptr; - ccan_list_del(&args->wfd.wfd_node); + RB_VM_LOCK_ENTER(); + { + ccan_list_del(&args->wfd.wfd_node); + } + RB_VM_LOCK_LEAVE(); if (args->read) rb_fd_term(args->read); if (args->write) rb_fd_term(args->write); if (args->except) rb_fd_term(args->except); -- 2.36.0