<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Hi all,</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>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:</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>void thread_main()</FONT></DIV>
<DIV><FONT size=2>{</FONT></DIV>
<DIV><FONT size=2>int* x = new int[100];</FONT></DIV>
<DIV><FONT size=2>delete [] x;</FONT></DIV>
<DIV><FONT size=2>}</FONT></DIV>
<DIV><FONT size=2> </DIV>
<DIV>
<DIV><FONT face=ËÎÌå size=2>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:</FONT></DIV>
<DIV><FONT face=ËÎÌå size=2>*** glibc detected *** double free or corruption
(fasttop): 0x00000001201d8a40 ***</FONT></DIV>
<DIV> </DIV>
<DIV>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!</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV>Thanks!</DIV>
<DIV> </DIV>
<DIV>Jiayuan</DIV></FONT></DIV></BODY></HTML>