From: "jpcamara (JP Camara) via ruby-core" Date: 2023-12-24T17:47:14+00:00 Subject: [ruby-core:115885] [Ruby master Bug#20076] M:N scheduler is stuck on macOS with RUBY_MN_THREADS=1 Issue #20076 has been updated by jpcamara (JP Camara). A one-line change fixes it for me, and fixes almost every failure I was seeing when running `test-all` using `RUBY_MN_THREADS=1`. Here is the change: https://github.com/ruby/ruby/pull/9344/files ```c static ssize_t rb_io_read_memory(rb_io_t *fptr, void *buf, size_t count) { VALUE scheduler = rb_fiber_scheduler_current(); if (scheduler != Qnil) { VALUE result = rb_fiber_scheduler_io_read_memory(scheduler, fptr->self, buf, count, 0); if (!UNDEF_P(result)) { return rb_fiber_scheduler_io_result_apply(result); } } struct io_internal_read_struct iis = { .th = rb_thread_current(), .fptr = fptr, .nonblock = 0, .fd = fptr->fd, .buf = buf, .capa = count, .timeout = NULL, }; struct timeval timeout_storage; if (fptr->timeout != Qnil) { timeout_storage = rb_time_interval(fptr->timeout); iis.timeout = &timeout_storage; } // previous line // VVVVVV // return (ssize_t)rb_thread_io_blocking_call(internal_read_func, &iis, fptr->fd, RB_WAITFD_IN); return (ssize_t)rb_thread_io_blocking_call(internal_read_func, &iis, fptr->fd, RB_WAITFD_IN | RB_WAITFD_OUT); } ``` There's almost _no way_ that it actually fixes the core issue. It has to be that it causes a fallback to some native 1:1 thread behavior. But it is extremely curious that this single change to `rb_io_read_memory` fixes the issue? ---------------------------------------- Bug #20076: M:N scheduler is stuck on macOS with RUBY_MN_THREADS=1 https://bugs.ruby-lang.org/issues/20076#change-105841 * Author: hsbt (Hiroshi SHIBATA) * Status: Open * Priority: Normal * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- This is known issue. I already shared this to ko1. The version of https://github.com/ruby/ruby/commit/28e3886689c71b22487dd5d0cb62f3b5ed0a77cc is crashed with `make exam`. This is happend with webrick test on `make test-tool`. My environment is macOS Sonoma 14.3 beta1 and ``` $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables package-id: com.apple.pkg.CLTools_Executables version: 15.1.0.0.1.1700200546 volume: / location: / install-time: 1702331495 ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/