On Jan 15, 2007, at 7:28 AM, MenTaLguY wrote: > I believe the two crashes are related. Also, it appears that the > corruption only happens with Queues, not other uses of Mutexes. > Likely > this means that some queue-specific routine expecting a queue is > getting > passed a pointer to a member of the queue instead, or a routine > expecting one member is getting passed another. The program below reproduces the problem, and surprisingly, I only use Mutex and ConditionVariable--no Queue. ======================================== require 'fastthread' require 'thread' class GlobalSpaceMux def initialize() @mutex = Mutex.new @condition = ConditionVariable.new @queue = Array.new @send_thread = Thread.new(&method(:send_thread_loop)) end def send_thread_loop loop do @mutex.synchronize do @condition.wait(@mutex) while @queue.empty? @queue.shift end end end end x = GlobalSpaceMux.new ======================================== $ gdb ~/ruby-1.8.5-p12/bin/ruby (gdb) r zzz-crash5.rb Starting program: /Users/youngh/ruby-1.8.5-p12/bin/ruby zzz-crash5.rb Reading symbols for shared libraries .. done Reading symbols for shared libraries . done Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000005 0x001772f8 in free_entries (first=0x1) at fastthread.c:74 74 next = first->next; (gdb) bt #0 0x001772f8 in free_entries (first=0x1) at fastthread.c:74 #1 0x00177368 in finalize_list (list=0x434614) at fastthread.c:85 #2 0x00177870 in finalize_mutex (mutex=0x434610) at fastthread.c:227 #3 0x00178550 in finalize_queue (queue=0x434610) at fastthread.c:562 #4 0x001785b4 in free_queue (queue=0x434610) at fastthread.c:572 #5 0x0002c8bc in rb_gc_call_finalizer_at_exit () at gc.c:1884 #6 0x00005e5c in ruby_finalize_1 () at eval.c:1549 #7 0x00006048 in ruby_cleanup (ex=0) at eval.c:1584 #8 0x00006274 in ruby_stop (ex=0) at eval.c:1615 #9 0x00006348 in ruby_run () at eval.c:1636 #10 0x00002bdc in main (argc=2, argv=0xbffff780, envp=0xbffff78c) at main.c:46 (gdb) --Young