Backport #9030

Backport r43334 (fix for SEGV with Refinements)

Added by Shugo Maeda 6 months ago. Updated 6 months ago.

[ruby-core:57909]
Status:Closed
Priority:Normal
Assignee:Tomoyuki Chikanaga

Description

=begin
Please backport r43334 to avoid SEGV when an undefined method is refined but the refinement is not used.
For example, the following program causes SEGV.

  class Foo
    def foo
    end

    undef foo
  end

  module FooExt
    refine Foo do
      def foo
      end
    end
  end

  begin
    Foo.new.foo # or Foo.new.send(:foo)
  end

=end

Associated revisions

Revision 43345
Added by Tomoyuki Chikanaga 6 months ago

merge revision(s) 43334: [Backport #9030]

* vm_insnhelper.c (vm_call_method): set ci->me to 0 when the
  original method of a refined method is undef to avoid SEGV.

* vm_method.c (rb_method_entry_without_refinements): return 0 when
  the original method of a refined method is undef to avoid SEGV.

* test/ruby/test_refinement.rb: related test.

History

#1 Updated by Tomoyuki Chikanaga 6 months ago

  • Status changed from Open to Assigned

#2 Updated by Tomoyuki Chikanaga 6 months ago

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

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


merge revision(s) 43334: [Backport #9030]

* vm_insnhelper.c (vm_call_method): set ci->me to 0 when the
  original method of a refined method is undef to avoid SEGV.

* vm_method.c (rb_method_entry_without_refinements): return 0 when
  the original method of a refined method is undef to avoid SEGV.

* test/ruby/test_refinement.rb: related test.

Also available in: Atom PDF