diff options
author | Aaron Patterson <[email protected]> | 2022-07-11 12:40:34 -0700 |
---|---|---|
committer | Aaron Patterson <[email protected]> | 2022-07-12 16:07:41 -0700 |
commit | de51bbcb544651fb499dd4cc757a2bf6f3b439cf (patch) | |
tree | 89d39a015ff0885895e82e859fec379c88455a0d /thread.c | |
parent | 59c6b7b7abefdf8bc93d7117a3893d581f3a6c90 (diff) |
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 <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6116
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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); |