Boost logo

Boost Users :

Subject: Re: [Boost-users] Troubleshooing deadlock with upgrade_lock<shared_mutex>
From: Ken Smith (smithkl42_at_[hidden])
Date: 2010-04-23 14:04:27


On Fri, Apr 23, 2010 at 10:57 AM, Frank Mori Hess <frank.hess_at_[hidden]>wrote:

> -----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#thread.synchronization.locks.upgrade_to_unique_lock),
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-multiple-reads-one-write
).

Ken Smith



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net