Project

General

Profile

Actions

Bug #22614

closed

Regressions: Adverse interactions between (unused) refinements and UnboundMethod#bind_call

Bug #22614: Regressions: Adverse interactions between (unused) refinements and UnboundMethod#bind_call

Added by alanwu (Alan Wu) 1 day ago. Updated 1 day ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:127650]

Description

# 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")
# 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)
# 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.
Actions

Also available in: PDF Atom