summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2022-09-17 14:05:23 +0900
committernagachika <nagachika@ruby-lang.org>2022-09-17 14:05:23 +0900
commit99d254d8b025fd952375ed15c345ecc1b806652a (patch)
tree1ca923bc601624c80f1a5721cc1079c670d3b82a /thread.c
parent87463832195eac16e9248e2a4a048c07f09582df (diff)
merge revision(s) de51bbcb544651fb499dd4cc757a2bf6f3b439cf: [Backport #18816]
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 <alanwu@ruby-lang.org> --- thread.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/thread.c b/thread.c
index cf6e89327e..9476a7986a 100644
--- a/thread.c
+++ b/thread.c
@@ -4501,7 +4501,11 @@ select_single_cleanup(VALUE ptr)
{
struct select_args *args = (struct select_args *)ptr;
- list_del(&args->wfd.wfd_node);
+ RB_VM_LOCK_ENTER();
+ {
+ 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);