
Caleb Thank you for taking the time to answer my email. I actually did use a mutex to protect my queue. I did another test very simple to reproduce the problem. A program creates N threads that construct & destroy objects in an object pool With N = 9, it crashes on linux Following is the source code of the program & the gdb trace. Thank you for your help #include <iostream> #include <boost/thread/thread.hpp> #include <boost/pool/poolfwd.hpp> #include <boost/pool/object_pool.hpp> class Foo; static boost::object_pool<Foo>* _pool; class Foo{ public: void handle(){ _pool->destroy(this); } }; class Bar{ public: Bar(){} void operator()(){ for(;;){ Foo* foo = _pool->construct(); foo->handle(); } } }; int main(int argc, char* argv[]) { if(argc != 2){ std::cout << "Usage: nbThrd" << std::endl; return 0; } int nbThrd = atoi(argv[1]); _pool = new boost::object_pool<Foo>(1000); boost::thread_group _threads; Bar bar; for (int i=0; i<nbThrd; ++i){ _threads.create_thread(bar); } _threads.join_all(); return 0; } Reading symbols from /lib/libdl.so.2...done. Loaded symbols for /lib/libdl.so.2 Reading symbols from /lib/tls/libpthread.so.0...done. Loaded symbols for /lib/tls/libpthread.so.0 Reading symbols from /lib/tls/librt.so.1...done. Loaded symbols for /lib/tls/librt.so.1 Reading symbols from /usr/lib/libstdc++.so.5...done. Loaded symbols for /usr/lib/libstdc++.so.5 Reading symbols from /lib/tls/libm.so.6...done. Loaded symbols for /lib/tls/libm.so.6 Reading symbols from /lib/libgcc_s.so.1...done. Loaded symbols for /lib/libgcc_s.so.1 Reading symbols from /lib/tls/libc.so.6...done. Loaded symbols for /lib/tls/libc.so.6 Reading symbols from /lib/ld-linux.so.2...done. Loaded symbols for /lib/ld-linux.so.2 #0 boost::pool<boost::default_user_allocator_new_delete>::ordered_malloc_ne ed_resize (this=0x8fc94c0) at simple_segregated_storage.hpp:46 46 { return *(static_cast<void **>(ptr)); } (gdb) where #0 boost::pool<boost::default_user_allocator_new_delete>::ordered_malloc_ne ed_resize (this=0x8fc94c0) at simple_segregated_storage.hpp:46 #1 0x08049559 in boost::object_pool<Foo, boost::default_user_allocator_new_delete>::construct (this=0x8fca760) at object_pool.hpp:76 #2 0x08049492 in boost::detail::function::void_function_obj_invoker0<Bar, void>::invoke (function_obj_ptr= {obj_ptr = 0x8fc9628, const_obj_ptr = 0x8fc9628, func_ptr = 0x8fc9628, data = "("}) at custom.cpp:26 #3 0x00138ef5 in boost::function0<void, std::allocator<boost::function_base> >::operator() (this=0x40417a70) at function_template.hpp:581 #4 0x00138145 in thread_proxy (param=0xbfffc950) at /home/tjamet/dev/boost_1_32_0/libs/thread/src/thread.cpp:113 #5 0x00454dec in start_thread () from /lib/tls/libpthread.so.0 #6 0x00224a2a in clone () from /lib/tls/libc.so.6 -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Caleb Epstein Sent: Saturday, August 06, 2005 11:31 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] Maybe a problem with boost::object_pool? On 8/5/05, Labour, Matthieu (MLPRO SF) <matthieu_labour@ml.com> wrote:
There are 2 threads. One thread creates Objects using boost::object_pool and enqueues them into a stl queue.
Are you using a mutex to protect the push/pop operations on the queue? If not, then this is your problem. -- Caleb Epstein caleb dot epstein at gmail dot com _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users -------------------------------------------------------- If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/ --------------------------------------------------------