[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

pthread + malloc = segfault



hi,

i have some threads and some mallocs. after a couple of malloc calls, i get a SIGSEGV from mallopt.

i compile the app (contains c and c++ files) with "gcc -g -O0 -lstdc++ -lpthread ..."
(the code works under windows and multithreaded c++ libs, so there aren't any faults in the code)


the callstack looks like this:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 49156 (LWP 11020)]
0x40186efa in mallopt () from /lib/libc.so.6
(gdb) where
#0  0x40186efa in mallopt () from /lib/libc.so.6
#1  0x40186145 in malloc () from /lib/libc.so.6
#2  0x0804a3fd in Buffer::checkSpace(unsigned long) (this=0x8089458, writelen=4) at common/Buffer.cpp:143
#3  0x0804a507 in Buffer::addDWORD(unsigned long) (this=0x8089458, val=831) at common/Buffer.cpp:178
#4  0x0805bfc0 in SearchCommand::handle(NetBuffer*) (this=0x8069348, input=0x80893d0) at server/SearchCommand.cpp:79
#5  0x080591c7 in CommandThread::run() (this=0x8089408) at server/CommandThread.cpp:30
#6  0x0804ba37 in Thread::threadProc(void*) (param=0x8089408) at Thread.h:68
#7  0x400d3d53 in pthread_start_thread () from /lib/libpthread.so.0
#8  0x400d3d99 in pthread_start_thread_event () from /lib/libpthread.so.0


should i link to special threadsafe c++ libs (and if, how) ?

thanks



Reply to: