Project

General

Profile

Actions

Bug #2692

closed

Ruby hangs after returning from rescue clause inside the block

Added by Uriel (Ilya Lopatkin) about 14 years ago. Updated almost 13 years ago.

Status:
Closed
ruby -v:
ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux]
[ruby-core:27969]

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


Related issues 1 (0 open1 closed)

Is duplicate of Backport191 - Bug #1584: return from lambda within 2 procs freezesClosed06/07/2009Actions
Actions #1

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 :

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.

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
=end

Actions #2

Updated by Uriel (Ilya Lopatkin) about 14 years ago

=begin
Thanks, patch works fine.
=end

Actions #3

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
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0