From: sam.rawlins@... Date: 2014-04-03T04:52:04+00:00 Subject: [ruby-core:61819] [ruby-trunk - Bug #9683] Segmentation fault when using default proc feature in ruby Hash object Issue #9683 has been updated by Sam Rawlins. Nobu, Is p466 an unreleased version? Is it ruby_2_0_0 branch? In any case, you are correct: can reproduce in 2.0.0-p451 and -353. 2.1.x seem to correctly SystemStackError. There remains a bug in trunk (and 2.1.x), however: the first SystemStackError seems to leave Ruby (or the thread) in a dirty state, if it is rescued. Similar to Eran's irb example above: $ cat 9683.rb a = Hash.new {|h,k| h[k] += 1} begin; a[1]; rescue SystemStackError; end a[1] $ ruby 9683.rb Segmentation fault This bug doesn't require reusing `a`: $ cat 9683b.rb a = Hash.new {|h,k| h[k] += 1} begin; a[1]; rescue SystemStackError; end b = Hash.new {|h,k| h[k] += 1} b[1] $ ruby 9683b.rb Segmentation fault But it _does_ seem to require the same cause of the Segmentation fault? $ cat 9683c.rb a = Hash.new {|h,k| h[k] += 1} def foo; foo end begin; foo; rescue SystemStackError; end begin; a[1]; rescue SystemStackError; end foo $ ruby 9683c.rb 9683c.rb:2: stack level too deep (SystemStackError) And the bug only occurs on the same thread: $ cat 9683d.rb a = Hash.new {|h,k| h[k] += 1} begin a[1] rescue SystemStackError end t = Thread.new { a[1] } t.join $ ruby 9683d.rb 9683d.rb:7: stack level too deep (SystemStackError) (These examples all used ruby trunk.) My patch above basically ignores whatever problem is occurring by avoiding the SystemStackError altogether. Maybe the easy solution, if not the correct one. ---------------------------------------- Bug #9683: Segmentation fault when using default proc feature in ruby Hash object https://bugs.ruby-lang.org/issues/9683#change-46049 * Author: Eran Barak Levi * Status: Open * Priority: Normal * Assignee: * Category: * Target version: * ruby -v: ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- ��� bruno-v2 rvm:(ruby-2.1.0) git:(master) ��� uname -a Darwin erans-mbp.intkontera.com 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64 ��� bruno-v2 rvm:(ruby-2.1.0) git:(master) ��� rvm -v rvm 1.25.19 (stable) by Wayne E. Seguin , Michal Papis [https://rvm.io/] ��� bruno-v2 rvm:(ruby-2.1.0) git:(master) ��� ruby -v ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0] ��� bruno-v2 rvm:(ruby-2.1.0) git:(master) ��� ruby -e "a = Hash.new {|h,k| h[k] += 1};a[1]" 2> output [1] 24934 segmentation fault ruby -e "a = Hash.new {|h,k| h[k] += 1};a[1]" 2> output more information in the attached files ---Files-------------------------------- ruby_2014-03-27-153720_Erans-MacBook-Pro.crash (45.3 KB) output (489 KB) 9683.patch (1.31 KB) -- https://bugs.ruby-lang.org/