Fastthread crash (Was: Re: building Ruby with dmalloc)

On Wed, 2007-01-17 at 11:02 +0900, Young H. wrote:

The program below reproduces the problem, and surprisingly, I only
use Mutex and ConditionVariable–no Queue.

I’ve reduced the test case you gave me down to:

    require 'fastthread'
    require 'thread'

    mutex = Mutex.new
    condition = ConditionVariable.new
    t = Thread.new do
      mutex.lock
      condition.wait mutex
    end
    exit

The problem, in this case, appears to be coping with the mutex and
condition variable getting destroyed at program exit while there is
still a thread waiting on the condition variable.

Simple waits on mutexes do not appear to be affected; for instance, this
does not crash for me:

    require 'fastthread'
    require 'thread'

    mutex = Mutex.new
    mutex.lock
    t = Thread.new do
      mutex.lock
    end
    exit

I’m currently unsure whether it’s related to the other (non-exit-time)
crash or not.

-mental

On Fri, 2007-01-19 at 01:11 +0900, MenTaLguY wrote:

The problem, in this case, appears to be coping with the mutex and
condition variable getting destroyed at program exit while there is
still a thread waiting on the condition variable.

Actually … that turns out to not be the problem. The thread is killed
and the wait queue empty by the time the condition variable is
finalized.

Bizzarely, what appears to be happening is that rb_queue_alloc is
getting called when creating mutexes and condition variables. Hence
free_queue is getting called when mutexes and condition variables are
destroyed, and chaos ensues.

At least it’s a simple problem, but it’s a WEIRD one.

-mental

It turns out that the fastthread crash is due to a bug in the Ruby
interpreter’s handling of allocator functions for anonymous classes:

http://rubyforge.org/tracker/index.php?func=detail&aid=7974&group_id=426&atid=1698

I will try to come up with a workaround.

-mental

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs