Bug #2728: ruby segfaults returning from dynamically defined method in ensure block
http://redmine.ruby-lang.org/issues/show/2728

Author: Ethan -
Status: Open, Priority: High
Category: core
ruby -v: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32] AND ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin9.8.0]

As best as I can work out, the conditions to reproduce this crash are:
1. A begin/ensure block yields to a block passed by Enumerable (maybe passed by any compiled function?). 
2. Control is forced to the ensure block from 'break' being called from Enumerable. 
3. The ensure block contains a call to a dynamically defined method (created using define_method). 
4. The dynamically defined method runs. 
5. Instead of returning from the dynamically defined method, ruby segfaults (on windows XP), or bus errors (on OS X). 

Happens on both Windows XP and Mac OS X (10.5.8). Script to reproduce and output are attached.


----------------------------------------
http://redmine.ruby-lang.org