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:
int* x = new int;
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.