Project

General

Profile

Actions

Backport #6438

closed

Ruby Queue in thread before fork causes segfault on GC

Added by slyphon (Jonathan Simms) almost 12 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
[ruby-core:45065]

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]

Actions #1

Updated by jeremyevans0 (Jeremy Evans) over 4 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])
Actions

Also available in: Atom PDF

Like0
Like0