Backport #2728

ruby segfaults returning from dynamically defined method in ensure block

Added by Ethan - about 2 years ago. Updated 10 months ago.

[ruby-core:28129]
Status:Assigned Start date:02/11/2010
Priority:High Due date:02/11/2010
Assignee:Koichi Sasada % Done:

0%

Category:core
Target version:-

Description

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.

ensure_dynamic_method.rb - Script which will reproduce the crash. (647 Bytes) Ethan -, 02/10/2010 01:26 am

ensure_dynamic_method_osx.output - Output from script on OS X 10.5.8 (3.4 kB) Ethan -, 02/10/2010 01:26 am

ensure_dynamic_method_xp.output - Output from script on windows XP (1.3 kB) Ethan -, 02/10/2010 01:26 am


Related issues

follows ruby-trunk - Bug #2729: `unexpected break' occurs when a proc is called in ensure Closed 02/10/2010

History

Updated by Ivan Samsonov about 2 years ago

It is reproducing on ruby 1.9.1p243 Mac OS X 1.6

Updated by Nobuyoshi Nakada about 2 years ago

  • Category set to core
  • Status changed from Open to Closed
Fixed in r26628.

Updated by Nobuyoshi Nakada about 2 years ago

  • Status changed from Closed to Assigned
  • Assignee set to Yuki Sonoda
  • Priority changed from High to Normal

Updated by Yusuke Endoh almost 2 years ago

  • Category set to core
  • Assignee changed from Yuki Sonoda to Koichi Sasada
  • Priority changed from Normal to High
r26628 caused new SEGV when executing rubyspec.
Though the detail is still under investigation, I temporarily reverted the commit.
It should not be backported to 1.9.1.

-- 
Yusuke Endoh <mame@tsg.ne.jp>

Also available in: Atom PDF