* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
76b06555d0
commit
f8e0e1647e
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Thu Oct 17 17:43:00 2013 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Thu Oct 17 17:38:36 2013 Koichi Sasada <ko1@atdot.net>
|
Thu Oct 17 17:38:36 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* gc.c, internal.h: rename ruby_xsizefree/realloc to
|
* gc.c, internal.h: rename ruby_xsizefree/realloc to
|
||||||
|
@ -1059,6 +1059,54 @@ class TestRefinement < Test::Unit::TestCase
|
|||||||
INPUT
|
INPUT
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_refine_undefed_method_and_call
|
||||||
|
assert_in_out_err([], <<-INPUT, ["NoMethodError"], [])
|
||||||
|
class Foo
|
||||||
|
def foo
|
||||||
|
end
|
||||||
|
|
||||||
|
undef foo
|
||||||
|
end
|
||||||
|
|
||||||
|
module FooExt
|
||||||
|
refine Foo do
|
||||||
|
def foo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
Foo.new.foo
|
||||||
|
rescue => e
|
||||||
|
p e.class
|
||||||
|
end
|
||||||
|
INPUT
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_refine_undefed_method_and_send
|
||||||
|
assert_in_out_err([], <<-INPUT, ["NoMethodError"], [])
|
||||||
|
class Foo
|
||||||
|
def foo
|
||||||
|
end
|
||||||
|
|
||||||
|
undef foo
|
||||||
|
end
|
||||||
|
|
||||||
|
module FooExt
|
||||||
|
refine Foo do
|
||||||
|
def foo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
Foo.new.send(:foo)
|
||||||
|
rescue => e
|
||||||
|
p e.class
|
||||||
|
end
|
||||||
|
INPUT
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def eval_using(mod, s)
|
def eval_using(mod, s)
|
||||||
|
@ -1903,8 +1903,14 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
|
|||||||
no_refinement_dispatch:
|
no_refinement_dispatch:
|
||||||
if (ci->me->def->body.orig_me) {
|
if (ci->me->def->body.orig_me) {
|
||||||
ci->me = ci->me->def->body.orig_me;
|
ci->me = ci->me->def->body.orig_me;
|
||||||
|
if (UNDEFINED_METHOD_ENTRY_P(ci->me)) {
|
||||||
|
ci->me = 0;
|
||||||
|
goto start_method_dispatch;
|
||||||
|
}
|
||||||
|
else {
|
||||||
goto normal_method_dispatch;
|
goto normal_method_dispatch;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
klass = ci->me->klass;
|
klass = ci->me->klass;
|
||||||
goto zsuper_method_dispatch;
|
goto zsuper_method_dispatch;
|
||||||
|
@ -670,7 +670,12 @@ rb_method_entry_without_refinements(VALUE klass, ID id,
|
|||||||
}
|
}
|
||||||
if (defined_class_ptr)
|
if (defined_class_ptr)
|
||||||
*defined_class_ptr = defined_class;
|
*defined_class_ptr = defined_class;
|
||||||
|
if (UNDEFINED_METHOD_ENTRY_P(me)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
return me;
|
return me;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user