merge revision(s) de51bbcb54: [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(-)
This commit is contained in:
nagachika 2022-09-17 14:05:23 +09:00
parent 8746383219
commit 99d254d8b0
2 changed files with 7 additions and 3 deletions

View file

@ -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);