Bug #9377
closedSeg fault on call of missing super from self.extended in a Module
Description
Seg fault on call of missing super from self.extended in a Module
on 2.1.0-p0 and on 2.1.0-dev
x86_64 linux
Code to reproduce:
module A
def foo; super end
def self.extended(obj)
instance_method(:foo).bind(obj).call
end
end
Object.new.extend A
(stack trace is attached)
Note that calling from after extend is okay: (but raises missing super error)
module A
def foo; super end
end
Object.new.extend(A).foo #=> in `foo': super: no superclass method `foo' for #<Object:0x007fabf43d2730> (NoMethodError)
Also note that calling from within the extend as before, but having the method defined is also okay (and raises no error)
Files
Updated by nobu (Nobuyoshi Nakada) over 12 years ago
- Description updated (diff)
Updated by nobu (Nobuyoshi Nakada) over 12 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r44527.
Joe, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
vm_insnhelper.c: revive r44455 for bound module method
- vm_insnhelper.c (
vm_search_super_method): when super called in a
boundUnboundMethodgenerated from a module, no superclass is
found since the current defined class is the module, then call
method_missingin that case. [ruby-core:59619] [Bug #9377]
Updated by nobu (Nobuyoshi Nakada) over 12 years ago
- Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: REQUIRED, 2.1: REQUIRED
Since 2.0, vm_search_superclass() doesn't traverse the receiver's ancestors.
It works just because an invalid klass is not dereferenced accidentally.
Updated by nagachika (Tomoyuki Chikanaga) over 12 years ago
- Backport changed from 1.9.3: DONTNEED, 2.0.0: REQUIRED, 2.1: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONE, 2.1: REQUIRED
r44527 was backported to ruby_2_0_0 at r45051.
Updated by nobu (Nobuyoshi Nakada) over 12 years ago
- Description updated (diff)
Updated by naruse (Yui NARUSE) over 12 years ago
- Backport changed from 1.9.3: DONTNEED, 2.0.0: DONE, 2.1: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONE, 2.1: DONE
ruby_2_1 r44843 merged revision(s) 44527,44552,44553.