From mboxrd@z Thu Jan 1 00:00:00 1970 From: jerrygonair at hotmail.com (Jiayuan Meng) Date: Thu, 14 Jun 2007 05:08:03 +0800 Subject: threadsafe malloc? Message-ID: Hi all, I am using crosstool to compile Alpha binaries and run it on the M5 simulator. I programmed the binary to be a multi-threaded application. where each thread simply allocate and deallocate a pointer: void thread_main() { int* x = new int[100]; delete [] x; } I am expecting that the "x"s in each thread is assigned to a different address in the heap. But when debugging the simulator I found that the 4 threads allocate exactly the same address to the 4 "x"s, thus, when they try to deallocate "x", it is freed four times and the application invokes an error: *** glibc detected *** double free or corruption (fasttop): 0x00000001201d8a40 *** We guess that this problem is due to a thread-unsafe malloc functions. does crosstool provide threadsafe system libraries(malloc)? I would appreciate your help very much! I am using demo-alpha.sh with gcc-3.4.5-glibc-2.3.5.dat, the linux version is set to 2.6.13. Thanks! Jiayuan -------------- next part -------------- An HTML attachment was scrubbed... URL: