We've got reports from some of our customers that they are getting
occasional segfaults when using Ruby Enterprise Edition in concert
with a library that is using threads and the Queue class. After some
research, we were able to narrow it down to what looks to be a junk
pointer in the Queue class' value_available ConditionVariable var
( the error occurs in eval.c#rb_thread_check(), when it attempts to
check the type of a thread inside the Queue's .value_available
ConditionVariable's .waiting List at the time of the GC calling
free_queue() ).
You can reproduce the error by doing the following:
ruby -rthread -e 'q = Queue.new; Thread.new { q.pop }; pid = fork;
if pid.nil?; q = nil; GC.start; else; puts "Waiting on #{pid}";
Process.wait(pid); end'
In REE, I get an error like the following:
wrong argument type Object (expected Thread) (TypeError)
In stock 1.8.7, I don't receive an error.
I believe what is happening is that at fork() time something is
trashing (or failing to copy) the thread entry for the Queue popper
thread that is in the original process' ConditionVariable .waiting
list. Can someone from the Phusion team verify this bug?
Thanks,
Chris Zelenak