Bug #22615
openBackport 1d214cd778 to ruby_3_4
Description
Please backport 1d214cd7786e916cd5b198eb58436a5e10b45cc3 (the fix for Bug #22475) to ruby_3_4.
Bug #22475 lists 3.4.11 and 3.4.12 as affected. It still reproduces on 3.4.13, the release from 2026-11-18 that includes the security fixes:
m = Module.new
c = Class.new { include m }
a = Module.new; b = Module.new
m.prepend a
m.prepend b
c.ancestors.count(b) # => 2 on 3.4.13, 1 on 3.4.9
Why the backport is needed: 3.4.13 is the only 3.4 release with the 2026-11-18 security fixes, so anyone taking it also takes this regression. I am affected by it. When the doubled module's method is wrapped by a library that calls the original through bind_call, such as sorbet-runtime, the duplicate becomes infinite recursion and SystemStackError.
Note: the commit does not apply cleanly to ruby_3_4, because the loop in rb_prepend_module differs there from master.
Related: Bug #22475, Bug #22257, https://github.com/ruby/ruby/pull/19552
No data to display