Troubleshooing deadlock with upgrade_lock<shared_mutex>

I'm a C++/boost newbie, so my apologies if this is a basic question.
I've got a multithreaded app that appears to be deadlocking when two threads
are trying to acquire an upgrade_lock

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 23 April 2010, Ken Smith wrote:
Periodically, the app stops responding. When it does, I can see that the transmit() method is working fine, but the createRoom() and deleteRoom() methods (on separate threads, obviously) appear to be deadlocked on the highlighted lines, waiting to acquire their upgrade_locks.
Am I doing something wrong? Any suggestions on troubleshooting this?
Yes, they are deadlocked because both upgrade locks are waiting for the other to release shared ownership so they can upgrade to unique ownership. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkvR33cACgkQ5vihyNWuA4XoTwCgrpAjRxmzjOcQP4J6rW4v0gpZ bOEAoJ/5V8nO3AO6Fbo8PlJaE+z0pTAc =qXzk -----END PGP SIGNATURE-----

On Fri, Apr 23, 2010 at 10:57 AM, Frank Mori Hess
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Friday 23 April 2010, Ken Smith wrote:
Periodically, the app stops responding. When it does, I can see that the transmit() method is working fine, but the createRoom() and deleteRoom() methods (on separate threads, obviously) appear to be deadlocked on the highlighted lines, waiting to acquire their upgrade_locks.
Am I doing something wrong? Any suggestions on troubleshooting this?
Yes, they are deadlocked because both upgrade locks are waiting for the other to release shared ownership so they can upgrade to unique ownership.
Perhaps I wasn't clear. They're not waiting on the upgrade_to_unique_lock lines, but on the upgrade_lock lines. So unless the upgrade_lock is automatically trying to acquire a unique lock (which would seem to go against the documentation, see http://www.boost.org/doc/libs/1_42_0/doc/html/thread/synchronization.html#th...), that's not the behavior that I would expect. Or am I missing something? Is there a right way to do this that I've missed? (I'm using the only example code I've been able to find, e.g., http://stackoverflow.com/questions/989795/example-for-boost-shared-mutex-mul... ). Ken Smith

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 23 April 2010, Ken Smith wrote:
Perhaps I wasn't clear. They're not waiting on the upgrade_to_unique_lock lines, but on the upgrade_lock lines.
Oh, I see the highlighting now. I generally don't read the html version of emails. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkvR5HkACgkQ5vihyNWuA4V29QCcDIs3NmfnjOsyR7uWtnfcgGKi JgUAoNvLPqOgIwpw+snqfwyaZoYRiA6P =gRIK -----END PGP SIGNATURE-----
participants (2)
-
Frank Mori Hess
-
Ken Smith