diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | KNOWNBUGS.rb | 18 | ||||
-rw-r--r-- | bootstraptest/test_flow.rb | 40 | ||||
-rw-r--r-- | vm.c | 16 |
4 files changed, 60 insertions, 20 deletions
@@ -1,3 +1,9 @@ +Sat Nov 3 04:14:19 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm.c (rb_vm_rewrite_ep_in_errinfo): rewrite all catch points in + errinfo, not only the topmost frame. based on the patch by + ktsj (Kazuki Tsujimoto) in [ruby-dev:45656]. [Bug #6460] + Fri Nov 2 20:11:17 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> * lib/mkmf.rb (MakeMakefile#timestamp_file): remove @ which looks like diff --git a/KNOWNBUGS.rb b/KNOWNBUGS.rb index 2bcedcb150..b97a08d928 100644 --- a/KNOWNBUGS.rb +++ b/KNOWNBUGS.rb @@ -3,21 +3,3 @@ # So all tests will cause failure. # -[['[ruby-dev:45656]', %q{ - class Bug6460 - include Enumerable - def each - begin - yield :foo - ensure - 1.times { Proc.new } - end - end - end - e = Bug6460.new -}]].each do |bug, src| - assert_equal "foo", src + %q{e.detect {true}}, bug - assert_equal "true", src + %q{e.any? {true}}, bug - assert_equal "false", src + %q{e.all? {false}}, bug - assert_equal "true", src + %q{e.include?(:foo)}, bug -end diff --git a/bootstraptest/test_flow.rb b/bootstraptest/test_flow.rb index d40d814fbc..0390062a24 100644 --- a/bootstraptest/test_flow.rb +++ b/bootstraptest/test_flow.rb @@ -543,9 +543,49 @@ assert_equal %Q{ENSURE\n}, %q{ end end e = Bug5234.new +}], + ['[ruby-dev:45656]', %q{ + class Bug6460 + include Enumerable + def each + begin + yield :foo + ensure + 1.times { Proc.new } + end + end + end + e = Bug6460.new }]].each do |bug, src| assert_equal "foo", src + %q{e.detect {true}}, bug assert_equal "true", src + %q{e.any? {true}}, bug assert_equal "false", src + %q{e.all? {false}}, bug assert_equal "true", src + %q{e.include?(:foo)}, bug end + +assert_equal "foo", %q{ + class Bug6460 + def m1 + m2 {|e| + return e + } + end + + def m2 + begin + yield :foo + ensure + begin + begin + yield :foo + ensure + Proc.new + raise '' + end + rescue + end + end + end + end + Bug6460.new.m1 +}, '[ruby-dev:46372]' @@ -434,7 +434,8 @@ vm_make_env_each(rb_thread_t * const th, rb_control_frame_t * const cfp, if (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { /* TODO */ env->block.iseq = 0; - } else { + } + else { rb_vm_rewrite_ep_in_errinfo(th, cfp); } return envval; @@ -493,9 +494,20 @@ rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp) return envval; } +static void vm_rewrite_ep_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp); + void rb_vm_rewrite_ep_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp) { + while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) { + vm_rewrite_ep_in_errinfo(th, cfp); + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); + } +} + +static void +vm_rewrite_ep_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp) +{ /* rewrite ep in errinfo to point to heap */ if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) && (cfp->iseq->type == ISEQ_TYPE_RESCUE || @@ -505,7 +517,7 @@ rb_vm_rewrite_ep_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp) VALUE *escape_ep = GET_THROWOBJ_CATCH_POINT(errinfo); if (! ENV_IN_HEAP_P(th, escape_ep)) { VALUE epval = *escape_ep; - if (CLASS_OF(epval) == rb_cEnv) { + if (!SPECIAL_CONST_P(epval) && RBASIC(epval)->klass == rb_cEnv) { rb_env_t *epenv; GetEnvPtr(epval, epenv); SET_THROWOBJ_CATCH_POINT(errinfo, (VALUE)(epenv->env + epenv->local_size)); |