Backport #6438
closedRuby Queue in thread before fork causes segfault on GC
Description
After many hours of debugging (with immeasurable help from Eric Lindvall), I've come across a pretty nasty bug in MRI 1.8.7 that affects p249-p358 on linux and OSX.
Eric came up with this reproduction:
require 'thread'
50.times { Thread.new { Queue.new.pop } }
Process.waitpid fork { GC.start; puts "In child: #{$$}" }
produces the output:
/tmp/fork-crash.rb:3: [BUG] Segmentation fault
ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin11.3.0]
More specifically, this seems to be a problem with a Thread waiting on a ConditionVariable when you fork
require 'thread'
50.times { Thread.new { m = Mutex.new; c = ConditionVariable.new; m.synchronize { c.wait(m) } } }
Process.waitpid fork { GC.start; puts "In child: #{$$}" }
produces the output:
/tmp/mutex-crash.rb:3: [BUG] Segmentation fault
ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin11.3.0]
Updated by jeremyevans0 (Jeremy Evans) over 5 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby 1.8 to Backport187
- Status changed from Open to Closed
- Target version deleted (
Ruby 1.8.7) - ruby -v deleted (
ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin11.3.0])