Re: [Boost-users] Maybe a problem with boost::object_pool?

Caleb Thanks for your answer. I tried running the following program with valgrind but as you said valgrind doesn't complain and I was unable to crash it. Without valgrind sometimes it works fine, sometimes it crashes.... I tested it on 4 different machines. On all of them I had crashes. So I doubt the memory is at fault. Sometimes it requires 20+ threads to crash it. But it crashes always at the same place. Here is an example of simple program + purify trace. I use Red Hat linux 3.2.3-47 Gcc version 3.2.3 20030502 Purify 2003a.05.15 Boost 1.32.0 #include <stdlib.h> #include <iostream> #include <boost/thread/thread.hpp> #include <boost/pool/poolfwd.hpp> #include <boost/pool/object_pool.hpp> class Foo{ public: int foo; }; static boost::object_pool<Foo>* _pool; class Bar{ public: Bar(){} void operator()(){ const int FOO_COUNT = 100; Foo* foo[FOO_COUNT]; int i; for(;;){ for(i=0; i<FOO_COUNT; i++){ try{ foo[i] = _pool->construct(); }catch(...){ std::cout << "exception:construct..." << std::endl; } } for(i=0; i<FOO_COUNT; i++) if (foo[i]){ try{ _pool->destroy(foo[i]); }catch(...){ std::cout << "exception:destroy..." << std::endl; } } } } }; 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>(10); boost::thread_group _threads; Bar bar; for (int i=0; i<nbThrd; ++i){ _threads.create_thread(bar); } _threads.join_all(); return 0; } **** Purify instrumented custom (pid 23146 at Tue Aug 9 18:13:32 2005) * Purify 2003a.06.15 Linux (32-bit) (c) Copyright IBM Corp. 1992, 2005 All rights reserved. * For contact information type: "purify -help" * For TTY output, use the option "-windows=no" * Command-line: custom 50 * Options settings: -g++=yes -purify -best-effort \ -cache-dir=/home/mlabour/tmp-mlabour-g++ -chain-length=20 \ -fds-inuse-at-exit=no -inuse-at-exit -max_threads=100 \ -purify-home=/tools/rational/2003a.06.15/releases/purify.i386_linux2.200 3a.06.15 \ -gcc3_path=/usr/bin/g++ -cache-dir=/home/mlabour/tmp-mlabour-g++ \ -hw_cap=yes -language=english * License successfully checked out. * Command-line: custom 50 **** Purify instrumented custom (pid 23146) **** MAF: Memory allocation failed (3 times): * This is occurring while in thread 27610032: malloc [rtlib.o] _ZnWjRkSt9nOtHrOw_t [libstdc++.so.5] operator new []( unsigned,std::nothrow_t const &) [libstdc++.so.5] boost::pool<boost::default_user_allocator_new_delete>::ordered_malloc_ne ed_resize( void) [pool.hpp:55] boost::object_pool<Foo,boost::default_user_allocator_new_delete>::constr uct( void) [object_pool.hpp:76] Bar::operator ()( void) [custom.cpp:27] boost::detail::function::void_function_obj_invoker0<Bar, void>::invoke(boost::detail::function::any_pointer) [function_template.hpp:128] boost::function0< void,std::allocator<boost::function_base>>::operator ()( void) const [function_template.hpp:581] thread_proxy [thread.cpp:113] start_thread [libpthread.so.0] clone [libc.so.6] * Attempt to allocate 335544328 bytes failed. **** Purify instrumented custom (pid 23146) **** COR: Fatal core dump: * This is occurring while in thread 1073758112: arena_get2 [libc.so.6] MaLlOc [libc.so.6] _dl_allocate_tls [] allocate_stack [libpthread.so.0] PtHrEaD_CrEaTe@@GlIbC_2.1 [libpthread.so.0] boost::thread::thread(boost::function0< void,std::allocator<boost::function_base>> const &) [thread.cpp:161] boost::thread_group::create_thread(boost::function0< void,std::allocator<boost::function_base>> const &) [thread.cpp:327] main [function_template.hpp:433] __libc_start_main [libc.so.6] _start [crt1.o] * Received signal 11 (SIGSEGV - Segmentation fault) * Handler function: SIG_DFL * Faulting address = 0x40b5e008 * Signal mask: (SIGHUP | SIGQUIT | SIGILL | SIGABRT | SIGBUS | \ SIGKILL | SIGSEGV | SIGALRM | SIGTERM | SIGCHLD | SIGSTOP | SIGSTP | \ SIGTTOU | SIGXFSZ | SIGVTALRM | SIGPWR | SIGUNUSED | SIGReserved35 | \ SIGReserved36 | SIGReserved38 | SIGReserved39 | SIGReserved42 | \ SIGReserved43 | SIGReserved44 | SIGReserved46 | SIGReserved47 | \ SIGReserved53 | SIGReserved54 | SIGReserved57 | SIGReserved58 | \ SIGReserved61 | SIGReserved62) * Pending signals: -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Caleb Epstein Sent: Tuesday, August 09, 2005 8:32 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] Maybe a problem with boost::object_pool? On 8/8/05, Labour, Matthieu (MLPRO SF) <matthieu_labour@ml.com> wrote:
A program creates N threads that construct & destroy objects in an object pool. With N = 9, it crashes on linux
That program works fine here with 1, 2, 4, 8, and 9 threads on a 2-way RedHat AS3.1 machine here. I've tried running it with "valgrind" and I don't get any errors. You might try running a memory test on your PC like memtest86. Perhaps you have bad RAM. -- 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/ --------------------------------------------------------

On 8/9/05, Labour, Matthieu (MLPRO SF) <matthieu_labour@ml.com> wrote:
I use Red Hat linux 3.2.3-47
Are you sure that is the version you're using? That doesn't look like a RedHat version number. What does "uname -a" tell you, and what is the contents of /etc/redhat-release? I have: Linux scsefpldcs0213 2.4.21-27.0.4.ELhugemem #1 SMP Sat Apr 16 18:22:53 EDT 2005 i686 i686 i386 GNU/Linux Red Hat Enterprise Linux AS release 3 (Taroon Update 4)
Gcc version 3.2.3 20030502
Perhaps the compiler is at fault here. Thats an old-ish version of GCC. I use 3.3.4. It could also be a buggy GNU libc or libstdc++ if you're on an older RedHat version. -- Caleb Epstein caleb dot epstein at gmail dot com
participants (2)
-
Caleb Epstein
-
Labour, Matthieu (MLPRO SF)