Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: jerrygonair at hotmail.com (Jiayuan Meng)
Subject: threadsafe malloc?
Date: Thu, 14 Jun 2007 05:08:03 +0800	[thread overview]
Message-ID: <BAY123-DAV9025687BE83D364A2864EA5180@phx.gbl> (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>

                 reply	other threads:[~2007-06-13 21:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

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