Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* threadsafe malloc?
@ 2007-06-13 21:08 jerrygonair
  0 siblings, 0 replies; only message in thread
From: jerrygonair @ 2007-06-13 21:08 UTC (permalink / raw)


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: <http://listman.redhat.com/archives/axp-list/attachments/20070614/873445e0/attachment.htm>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-13 21:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-13 21:08 threadsafe malloc? jerrygonair

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox