Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-10-05 16:02:50


Kurt Kohler wrote:
> I've run into a strange problem using shared_ptr which I've reduced to
> the following simple case.
>
> #include <tr1/memory>
>
> class X
> {
> public:
> typedef std::tr1::shared_ptr<X> Ptr;
>
> int x;
> };
>
> int main(int argc, char *argv[])
> {
> for (int i = 0; i < 100; i++)
> {
> X::Ptr pX(new X);
> }
>
> return EXIT_SUCCESS;
> }
>
> Compiling with g++ 4.0.1 on a Debian system with "-O0 -g -fno-inline
> -DDEBUG". When this program is run under Valgrind (MemCheck) repeated
> messages like the following occur.
>
> ==9950== Conditional jump or move depends on uninitialized value(s)
> ==9950== at 0x1BBB6D9A: pthread_mutex_lock (in
> /lib/tls/libpthread-2.3.5.so)
> ==9950== by 0x1BB56C75: pthread_mutex_lock (in
> /lib/tls/libc-2.3.5.so) ==9950== by 0x804BF29:
> __gthread_mutex_lock(pthread_mutex_t*) (gthr-default.h:510)
> ==9950== by 0x8057ACD: std::tr1::_Sp_counted_base::release()
> (boost_shared_ptr.h:148)

You seem to be using libstdc++'s implementation of shared_ptr; if the
problem doesn't occur with boost::shared_ptr, a better place to ask this
question would be libstdc++'s own mailing list.


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