lsegal/yard — pull request #717 by msonnabaum (2013-12-09 22:12:20+00:00)
Title: Handle mutex deadlocks in logger.

I was gettintg this error when trying to use the rake task:

```
deadlock; recursive locking
:8:in `lock'
:8:in `synchronize'
vendor/bundle/ruby/1.9.1/gems/yard-0.8.7.3/lib/yard/logging.rb:92:in `progress'
vendor/bundle/ruby/1.9.1/gems/yard-0.8.7.3/lib/yard/logging.rb:101:in `block (2 levels) in progress'
:10:in `synchronize'
vendor/bundle/ruby/1.9.1/gems/yard-0.8.7.3/lib/yard/logging.rb:100:in `block in progress'
```

However, I did not get that error when running yard directly.

Looking at https://github.com/lsegal/yard/blob/master/lib/yard/logging.rb#L92, line 97 starts a new thread, and then within a ```@mutex.synchronize``` it calls the current method recursively. When that thread hits line 92, it's trying to use the same ```@mutex``` instance before it has been released.

This appears to be throwing constant exceptions, but they are silent. If ```Thread.abort_on_exception = true```. is added, you get the error above almost instantly.

I discovered that this was failing for me because a gem is loaded in my Rakefile that has ```Thread.abort_on_exception = true```.

Handling the exception seems a sensible enough fix.