Boost logo

Boost Users :

From: Colin Fox (cfox_at_[hidden])
Date: 2002-02-15 13:47:39


Greetings, everyone.

I'm currently having some trouble with a heavily multithreaded app which
uses objects shared between threads via smart pointers.

It's a multi-user application, where each user has a thread, and when
one user sends a message to another (or broadcasts to all), a message
object is created, and a smart pointer to that message is put into a
queue for each thread.

I'm using pthread_mutex for locking the queues for each thread.

This program will sometimes work flawlessly for hours, and other times
it will die within moments of starting. Pretty much every time it dies,
it's because the message object has been freed while there are still
smart pointers pointing to it.

I know that the recent version of the smart pointer library was supposed
to have added thread-safety to it, but I'm wondering if anyone else is
having similar troubles.

I'm using gcc 3.0.3 on Linux, and boost 1.27.

I also discovered some things in the gcc documentation having to do with
threads, (eg: when you compile the compiler, you have to tell it to
build multi-threaded programs). And there are various threading flags
that can be used during a compile, and I'm not sure which to use (or all
of them?): -D_PTHREADS -D_REENTRANT -pthread : I'm using all those right
now. Is that wrong?

Any help would be greatly appreciated. It's driving me mad! :)

Regards,
  Colin

-- 
Colin Fox
CF Consulting Inc.
cfox_at_[hidden]

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