Project

General

Profile

Actions

Bug #9377

closed

Seg fault on call of missing super from self.extended in a Module

Added by jemc (Joe McIlvain) almost 11 years ago. Updated almost 11 years ago.

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

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)

module ABase
  def foo; end
end

module A
  include ABase
  def foo; super end

  def self.extended(obj)
    instance_method(:foo).bind(obj).call
  end
end

Object.new.extend A

Files

segfault.txt (10 KB) segfault.txt jemc (Joe McIlvain), 01/07/2014 04:15 PM

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) almost 11 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
    bound UnboundMethod generated from a module, no superclass is
    found since the current defined class is the module, then call
    method_missing in that case. [ruby-core:59619] [Bug #9377]

Updated by nobu (Nobuyoshi Nakada) almost 11 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) almost 11 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) almost 11 years ago

  • Description updated (diff)

Updated by naruse (Yui NARUSE) almost 11 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0