Project

General

Profile

Actions

Backport #8966

closed

SEGV when a refined method is undefined by undef

Added by shugo (Shugo Maeda) about 11 years ago. Updated about 11 years ago.


Description

=begin
The following code causes SEGV:

module Foo
refine Object do
def foo
puts "foo"
end
end
end

using Foo

class Object
undef foo
end

foo

I guess undef is not aware of refinements.
=end

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

  • Description updated (diff)

=begin
What should happen in that case?
Printing (({"foo"})), or raising a (({NameError}))?
=end

Updated by shugo (Shugo Maeda) about 11 years ago

nobu (Nobuyoshi Nakada) wrote:

What should happen in that case?
Printing (({"foo"})), or raising a (({NameError}))?

`undef foo' should raise a NameError because foo is not defined in the original class.

Updated by nagachika (Tomoyuki Chikanaga) about 11 years ago

  • Status changed from Assigned to Closed
  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: UNKNOWN, 2.0.0: REQUIRED

committed at r43090.
And it should be backported to ruby_2_0_0.

Actions #4

Updated by nagachika (Tomoyuki Chikanaga) about 11 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport200
  • Category deleted (core)
  • Status changed from Closed to Assigned
  • Assignee changed from shugo (Shugo Maeda) to nagachika (Tomoyuki Chikanaga)
  • Target version deleted (2.1.0)

Updated by shugo (Shugo Maeda) about 11 years ago

nagachika (Tomoyuki Chikanaga) wrote:

committed at r43090.
And it should be backported to ruby_2_0_0.

Ah, I forgot to add the bug number to the commit log of r43090. Thanks.

Actions #6

Updated by nagachika (Tomoyuki Chikanaga) about 11 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r43143.
Shugo, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 43090,43091: [Backport #8966]

* vm_method.c (rb_undef): raise a NameError if the original method
  of a refined method is not defined. 

* vm_insnhelper.c (rb_method_entry_eq): added NULL check to avoid SEGV.

* test/ruby/test_refinement.rb: related test.
  of a refined method is not defined.
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0