Project

General

Profile

Backport #8966

SEGV when a refined method is undefined by undef

Added by shugo (Shugo Maeda) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:57466]

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

Associated revisions

Revision 3cfa0074
Added by nagachika (Tomoyuki Chikanaga) over 5 years ago

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 43143
Added by nagachika (Tomoyuki Chikanaga) over 5 years ago

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.

History

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

  • Description updated (diff)

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

Updated by shugo (Shugo Maeda) over 5 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) over 5 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.

#4

Updated by nagachika (Tomoyuki Chikanaga) over 5 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk 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) over 5 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.

#6

Updated by nagachika (Tomoyuki Chikanaga) over 5 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.

Also available in: Atom PDF