|
Boost Users : |
Subject: [Boost-users] [Thread] barrier destruction after wait() results in assertion
From: Peter Klotz (Peter.Klotz_at_[hidden])
Date: 2008-12-03 09:57:57
Boost 1.37.0, Red Hat Enterprise Linux 5 x86_64, gcc 4.1:
The following simple test establishes a barrier with thread count 2.
One of the threads destroys the barrier after returning from wait(). This results in sporadic assertions from ~mutex().
boost/thread/pthread/mutex.hpp:45: boost::mutex::~mutex(): Assertion `!pthread_mutex_destroy(&m)' failed.
#1 0x00000038306295d6 in __assert_fail () from /lib64/libc.so.6
#2 0x000000000040245a in ~mutex (this=0x1f63f010) at boost/thread/pthread/mutex.hpp:45
#3 0x0000000000402488 in ~barrier (this=0x1f63f010) at boost/thread/barrier.hpp:24
I assume that this usage of barrier is not supported/allowed. One cannot assume that the barrier can be destroyed just because the corresponding thread returned from wait().
Is this conclusion correct?
Regards, Peter.
#include <boost/scoped_ptr.hpp>
#include <boost/thread/barrier.hpp>
#include <boost/thread/thread.hpp>
boost::scoped_ptr<boost::barrier> barrier;
void f()
{
barrier->wait();
}
int main(void)
{
barrier.reset(new boost::barrier(2));
boost::thread thread(boost::bind(&f));
barrier->wait();
barrier.reset();
thread.join();
return 0;
}
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