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
#include <iostream>
#include
#include
#include
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; iconstruct();
}catch(...){
std::cout <<
"exception:construct..." << std::endl;
}
}
for(i=0; idestroy(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; iboost::default_user_allocator_new_delete::ordered_malloc_ne
ed_resize( void) [pool.hpp:55]
boost::object_pool::constr
uct( void) [object_pool.hpp:76]
Bar::operator ()( void) [custom.cpp:27]
boost::detail::function::void_function_obj_invoker0::invoke(boost::detail::function::any_pointer)
[function_template.hpp:128]
boost::function0<
void,std::allocatorboost::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::allocatorboost::function_base> const &) [thread.cpp:161]
boost::thread_group::create_thread(boost::function0<
void,std::allocatorboost::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) 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/
--------------------------------------------------------