Skip to content

Commit

Permalink
Use VM Lock when mutating waiting threads list
Browse files Browse the repository at this point in the history
`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>
  • Loading branch information
tenderlove and XrXr committed Jul 12, 2022
1 parent 59c6b7b commit de51bbc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion thread.c
Expand Up @@ -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);
Expand Down

0 comments on commit de51bbc

Please sign in to comment.