From: "alanwu (Alan Wu) via ruby-core" Date: 2026-11-21T00:26:52+00:00 Subject: [ruby-core:127650] [Ruby Bug#22614] Regressions: Adverse interactions between (unused) refinements and UnboundMethod#bind_call Issue #22614 has been reported by alanwu (Alan Wu). ---------------------------------------- Bug #22614: Regressions: Adverse interactions between (unused) refinements and UnboundMethod#bind_call https://bugs.ruby-lang.org/issues/22614 * Author: alanwu (Alan Wu) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ```ruby # a.rb module M; end class A < Array; include M; end using(Module.new { refine(M) { def first = super } }) p A.instance_method(:first).bind_call(0x6f56) # [BUG] Segmentation fault at 0x000000000000dead __END__ Correct NoMethodError in v4.0.10, but regressed to a crash on trunk. (b3e890bf95 "Fix Module#instance_method directly on module for refined methods") ``` ```ruby # b.rb module M; def first = super; end class A < Array; include M; end module R; refine(M) { def first = 1 }; end # never using'ed p A.new.method(:first).unbind.bind_call(0x6f56) # [BUG] Segmentation fault at 0x000000000000dead __END__ Behavior of this changed since a838f980f5 (v3.4.x) and then since a4dff09be7 "[Bug #21673] Fix resolving refined module-defined method" (v4.0.x, and v3.4.8) ``` ```ruby # c.rb class C1; def m = :C1; end; class U; end module M2; def m = super; end U.include M2 p((U.new.method(:m).unbind.bind_call(C1.new) rescue $!.class)) module R; refine(M2) { def m = :unused }; end p((U.new.method(:m).unbind.bind_call(C1.new) rescue $!.class)) __END__ :C1 NoMethodError Should be :C1 twice, since the never-activated refinement shouldn't change the output. v3.3.x was correct. ``` -- 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/