Bug #2692
closedRuby hangs after returning from rescue clause inside the block
Description
=begin
Here is the sample code:
def foo
some_block = -> do
0.upto(1000) do |i|
begin
raise Exception.new if i % 500 == 0
rescue Exception
return
end
end
end
some_block.call
end
foo
VM hangs after return statement and can't be even interrupted via Ctrl+C.
I've tried the latest snapshot and it behaves the same.
=end
Updated by mame (Yusuke Endoh) about 14 years ago
- Category set to core
- Assignee set to ko1 (Koichi Sasada)
- Priority changed from Normal to 5
=begin
Hi Ilya --
2010/1/30 Ilya Lopatkin redmine@ruby-lang.org:
def foo
some_block = -> do
0.upto(1000) do |i|
begin
raise Exception.new if i % 500 == 0
rescue Exception
return
end
end
endsome_block.call
endfoo
VM hangs after return statement and can't be even interrupted via Ctrl+C.
I've tried the latest snapshot and it behaves the same.
Good report! Duplicated.
Here is a patch:
diff --git a/bootstraptest/test_jump.rb b/bootstraptest/test_jump.rb
index 7746733..bfb380e 100644
--- a/bootstraptest/test_jump.rb
+++ b/bootstraptest/test_jump.rb
@@ -259,3 +259,15 @@ assert_normal_exit %q{
end
end
}
+
+assert_normal_exit %q{
- -> do
- 1.times do
-
begin
-
raise
-
rescue
-
return
-
end
- end
- end.call
+}
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 54d54ff..ae1d86d 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1491,7 +1491,7 @@ vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp,
dfp = cfp->dfp;
goto valid_return;
}
-
tdfp = GC_GUARDED_PTR_REF((VALUE *)*dfp);
-
tdfp = GC_GUARDED_PTR_REF((VALUE *)*tdfp); } } }
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Updated by Uriel (Ilya Lopatkin) about 14 years ago
=begin
Thanks, patch works fine.
=end
Updated by mame (Yusuke Endoh) almost 14 years ago
- Status changed from Open to Closed
=begin
Hi,
This ticket was duplicated by #2692, and that was already fixed
by the almost same patch (r26524). Thanks.
--
Yusuke Endoh mame@tsg.ne.jp
=end