# Weird deadlock message

**URL:** <https://www.ruby-forum.com/t/weird-deadlock-message/143398>\
**Category:** Ruby\
**Created:** [July 18, 2008, 2:45am UTC](https://www.ruby-forum.com/t/weird-deadlock-message/143398 "2008-07-18T02:45:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [July 18, 2008, 2:45am UTC](https://www.ruby-forum.com/t/weird-deadlock-message/143398/1 "2008-07-18T02:45:34Z")

</div>

So…I run an app with three threads running, it churns for awhile,  
then…

./lib/logger.rb:88:in `flush': Thread(0x346fc): deadlock (fatal) from ./lib/logger.rb:88:in`log’  
from driver.rb:547:in `go' from driver.rb:784:in`doAllPeersWithDelta’  
from driver.rb:783:in `times' from driver.rb:783:in`doAllPeersWithDelta’  
from driver.rb:1004:in `startAllPeersAndWaitForCompletion' from driver.rb:708:in`doSingleRunWithCurrentSettings’  
from driver.rb:474:in `doMultiple' from driver.rb:463:in`upto’

This is flush called on a file socket. deadlock flushing a file? Bug?  
Thoughts?  
=R

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [July 18, 2008, 5:15am UTC](https://www.ruby-forum.com/t/weird-deadlock-message/143398/2 "2008-07-18T05:15:15Z")

</div>

On Jul 17, 2008, at 6:40 PM, Roger P. wrote:

> from driver.rb:463:in `upto’
> 
> This is flush called on a file socket. deadlock flushing a file? Bug?  
> Thoughts?

it’s not a file flushing, it’s logger class, check out the stacktrace

- probably you have a thread bug there - looks like soap btw,  
sorry! 😉

a @ [http://codeforpeople.com/](http://codeforpeople.com/)

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [July 18, 2008, 5:33am UTC](https://www.ruby-forum.com/t/weird-deadlock-message/143398/3 "2008-07-18T05:33:41Z")

</div>

> it’s not a file flushing, it’s logger class, check out the stacktrace
> 
> - probably you have a thread bug there - looks like soap btw,  
> sorry! 😉

Thankfully it’s not soap 🙂 soap is dirty! lol.  
Yeah it’s my own logger class calling flush on a file descriptor. Any  
thoughts? Ruby Bug?  
-R

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [July 18, 2008, 5:53am UTC](https://www.ruby-forum.com/t/weird-deadlock-message/143398/4 "2008-07-18T05:53:54Z")

</div>

On Jul 17, 2008, at 9:28 PM, Roger P. wrote:

> Thankfully it’s not soap 🙂 soap is dirty! lol.

i agree!

> Yeah it’s my own logger class calling flush on a file descriptor. Any  
> thoughts? Ruby Bug?

hrrrm - dunno. paste the code?

a @ [http://codeforpeople.com/](http://codeforpeople.com/)

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [July 18, 2008, 6:39am UTC](https://www.ruby-forum.com/t/weird-deadlock-message/143398/5 "2008-07-18T06:39:44Z")

</div>

> hrrrm - dunno. paste the code?
> 
> a @ [http://codeforpeople.com/](http://codeforpeople.com/)

def log(message)  
begin  
newMessage = formatMessage(message)  
print newMessage unless @@output\_to\_file\_only\_not\_screen  
if !@logFile or @logFile.closed?  
print “ERROR LOGGING THIS!!!” \<\< newMessage \<\< “\n\n\n”  
return  
end  
assert @logFile and !@logFile.closed?  
@logFile.write(newMessage)  
@logFile.flush # THIS LINE FAILS DEADLOCK. As a side note, I’ve  
had it fail on win32 for me on this line with an EBADF, but the instance  
in question is a deadlock in mac os x, using 1.8.6 or 1.8.7 SVN.  
rescue Exception =\> detail # obviously this does not catch the  
exception ‘deadlock’ 😛  
…  
end  
end

An over aggressive deadlock bug? A faulty fastthread?  
It might be another of those cruddy OS X bugs. Knowing my luck. [1]  
Note that in a similar but slightly different configuration it actually  
has one thread ‘freeze’ when it is opening a file [like File.new ‘abc’,  
‘w’].  
The fix thus far has been to avoid using threads, as I have never seen  
it in a single threaded environment. Cross your fingers, anyway.

Thanks for your help 🙂  
-R

[1] [Help me debug my stack trace - Ruby - Ruby-Forum](http://www.ruby-forum.com/topic/153559)
