The following code seems to deadlock on the second (read) scoped lock (not what I would expect): boost::read_write_mutex mutex(boost::read_write_scheduling_policy::alternating_single_read); { boost::read_write_mutex::scoped_write_lock writeLock(mutex); } { boost::read_write_mutex::scoped_read_lock readLock(mutex); }
Gordon Smith wrote:
The following code seems to deadlock on the second (read) scoped lock (not what I would expect):
boost::read_write_mutex mutex(boost::read_write_scheduling_policy::alternating_single_read); {
boost::read_write_mutex::scoped_write_lock writeLock(mutex);
}
{
boost::read_write_mutex::scoped_read_lock readLock(mutex);
}
There are some definite problems with read_write_mutex in the 1.31 release and this is one of them. Unfortunately the unit tests were quite lacking and didn't catch a bug as simple as this. I have a fixed read_write_mutex that I'm nearly ready to check in. I'm not happy with it--the code is too complex and the mutex object is too big, but at least it's a lot more correct, I hope. I have also expanded the unit tests. Probably too much, in fact: they check a lot more, but there is some duplication and they take quite a long time to run. Mike
I assume you meant 1.32?
Gordon.
"Michael Glassford"
Gordon Smith wrote:
The following code seems to deadlock on the second (read) scoped lock (not what I would expect):
boost::read_write_mutex mutex(boost::read_write_scheduling_policy::alternating_single_read); {
boost::read_write_mutex::scoped_write_lock writeLock(mutex);
}
{
boost::read_write_mutex::scoped_read_lock readLock(mutex);
}
There are some definite problems with read_write_mutex in the 1.31 release and this is one of them. Unfortunately the unit tests were quite lacking and didn't catch a bug as simple as this.
I have a fixed read_write_mutex that I'm nearly ready to check in. I'm not happy with it--the code is too complex and the mutex object is too big, but at least it's a lot more correct, I hope. I have also expanded the unit tests. Probably too much, in fact: they check a lot more, but there is some duplication and they take quite a long time to run.
Mike
Michael Glassford wrote:
Gordon Smith wrote:
The following code seems to deadlock on the second (read) scoped lock (not what I would expect):
[snip]
There are some definite problems with read_write_mutex in the 1.31 release and this is one of them. Unfortunately the unit tests were quite lacking and didn't catch a bug as simple as this.
This fix is now checked in, as well as expanded unit tests. As I indicated before, I'm not very happy with the read/write mutex (it's too too complex--and therefore error-prone--and takes up more memory than I would like). The design should be redone when the new interface is implemented. Mike
participants (2)
-
Gordon Smith
-
Michael Glassford