Project

General

Profile

Backport #6438

Ruby Queue in thread before fork causes segfault on GC

Added by slyphon (Jonathan Simms) over 7 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
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]

History

#1

Updated by jeremyevans0 (Jeremy Evans) 5 months ago

  • ruby -v deleted (ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin11.3.0])
  • Target version deleted (Ruby 1.8.7)
  • Status changed from Open to Closed
  • Project changed from Ruby 1.8 to Backport187
  • Tracker changed from Bug to Backport

Also available in: Atom PDF