--H+4ONPRPur6+Ovig
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Kirk Haines (khaines / enigo.com) wrote:

> On Wed, 18 Aug 2004 08:10:56 +0900, Florian Gross wrote
> 
> > Hm, an EINVAL exception shouldn't cause Thread deadlocks AFAIK. 
> > (Thread deadlocks are caused by the fatal exception, I think.)
> 
> I should have been clearer.  I have not been able to get a thread
> deadlock to occur.  So far the only error I have been able to cause to
> occur is the EINVAL error that occurs when the socket goes away before
> WEBrick can return a response.  It's not a fatal error.  It is simply
> caught and delivered to the logs, but it does cause a connection to
> effectively be dropped.

The right (wrong) sequence of locking can easily create a deadlock in
the right circumstances.  I can generate a deadlock easily in Borges due
to do an incorrect sequence of locks after an exception kills a thread.
(The exception is only important because it allows the threads to
deadlock.)

Here's a really simple example:

$ cat x.rb
Thread.start do Thread.stop end

Thread.stop

$ ruby x.rb
deadlock 0x806ccb0: sleep:-  - x.rb:1
deadlock 0x80788f8: sleep:- (main) - x.rb:3
x.rb:3:in `stop': Thread(0x80788f8): deadlock (fatal)
        from x.rb:3

(Mutex#lock calls Thread.stop)

-- 
Eric Hodel - drbrain / segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04


--H+4ONPRPur6+Ovig
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQFBIqlnMypVHHlsnwQRAryvAJ9KMiuJVy4v1chJeA8OjBnDJ8JNdACgoNvu
M/gPX3OAqSs+FBi6uVhSHlwnJF
-----END PGP SIGNATURE-----

--H+4ONPRPur6+Ovig--