f5373f55bb (ruby_4_0): Fix mutex_free so it doesn't call into Ruby code during GC

0 views
Skip to first unread message

Luke Gruber

unread,
Jun 9, 2026, 7:43:03 PM (13 hours ago) Jun 9
to ruby...@g.ruby-lang.org
Luke Gruber 2026-06-04 13:31:07 +0000 (Thu, 04 Jun 2026)

New Revision: f5373f55bb

https://github.com/ruby/ruby/commit/f5373f55bb

Log:
Fix mutex_free so it doesn't call into Ruby code during GC

While freeing a locked mutex, if there is a waiter for the
mutex it could call `rb_fiber_scheduler_unblock` which calls
into Ruby code.

The function `rb_mutex_unlock_th` was a footgun because it was used
during normal Ruby code and also during GC. The fix is to not call this
function during GC and simply remove the mutex from th->keeping_mutexes.

Fixes [Bug #22096] (Backport)

Modified files:
thread_sync.c
Reply all
Reply to author
Forward
0 new messages