From: "byroot (Jean Boussier) via ruby-core" Date: 2026-06-10T18:22:05+00:00 Subject: [ruby-core:125669] [Ruby Bug#22098] THREAD_EVENT_RESUMED runs without GVL held Issue #22098 has been updated by byroot (Jean Boussier). > But I think the bigger question is are we allowed to allocate in this callback? Doing so seems broken today and I also don't think it should be allowed. I'm fine with adding that restriction is there really isn't any other solution, but ideally we'd make the necessary changes to allow it. These callbacks typically want to record information, and `THREAD_EVENT_RESUMED` is the ideal hooks to update whatever statistics were collected. > so it would need to be copied to many call sites (~10). Is that inevitable, or could it be solved with a bit of a refactoring. (Sorry, the scheduler code is all but fresh in my head, I'm still unclear on what you are suggesting exactly) ---------------------------------------- Bug #22098: THREAD_EVENT_RESUMED runs without GVL held https://bugs.ruby-lang.org/issues/22098#change-117532 * Author: luke-gru (Luke Gruber) * Status: Open * Assignee: luke-gru (Luke Gruber) * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Today, it's possible to get a deadlock when allocating during a hook for this event. I attached a reproduction script using the `gvltools` gem. One way to fix it would be to not allocate during this hook and change the documentation to be clear that the GVL is not held. Any gems relying on this behavior, like `gvltools`, would need to be patched. Another way to approach it would be to change the call site for this hook invocation. I believe it would need to be added to quite a few places. To maintain Ractor safety, it would also need to be invoked without any locks held. I'm curious about your thoughts @byroot. ---Files-------------------------------- repro.rb (3.11 KB) run_loop.sh (2.82 KB) -- 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/lists/ruby-core.ml.ruby-lang.org/