This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/9721] New: dl-tls.c: tls_get_addr, etc, allocate using __libc_memalign but free with free - causes problems if you link a different malloc/free/etc library
- From: "cr at progress dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 8 Jan 2009 11:14:37 -0000
- Subject: [Bug libc/9721] New: dl-tls.c: tls_get_addr, etc, allocate using __libc_memalign but free with free - causes problems if you link a different malloc/free/etc library
- Reply-to: sourceware-bugzilla at sourceware dot org
We link with ptmalloc3 for performance reasons, but find that using thread-local
storage (in dlopen'ed libraries, though that may not be relevant) causes crashes.
Valgrind shows memory has been allocated with it's memalign, but freed with
ptmalloc3's free:
==24649== Thread 4:
==24649== Invalid read of size 4
==24649== at 0x83951C3: free (ptmalloc3.c:764)
==24649== by 0x348B1A: ___tls_get_addr (in /lib/ld-2.3.4.so)
==24649== by 0x1708E88F: ShutdownLibrary (TimeFormatPlugin.cpp:934)
==24649== by 0x8285F85: CorrelatorPluginType::~CorrelatorPluginType()
(CorrelatorPlugin.cpp:524)
==24649== by 0x81669D0: ....
...
==24649== Address 0x66613BC is 4 bytes before a block of size 4 alloc'd
==24649== at 0x4005F7F: memalign (m_replacemalloc/vg_replace_malloc.c:332)
==24649== by 0x348BC8: ___tls_get_addr (in /lib/ld-2.3.4.so)
==24649== by 0x14F7988F: ???
==24649== by 0x8285F85: CorrelatorPluginType::~CorrelatorPluginType()
(CorrelatorPlugin.cpp:524)
==24649== by 0x81669D0: ....
...
I think when running natively, the allocation occurs from libc's __libc_memalign
in /lib/libc.so but the free from ptmalloc3.
This is on Redhat Enterprise 4, but looking in CVS the trunk is the same -
calling __libc_memalign and free.
Is there a particular reason to use inconsistent prefixes on the symbols? If it
used __libc_memalign and __libc_free or memalign and free, I believe it would
fix our problem; would it cause other problems?
We are working around it by including a __libc_memalign symbol in ptmalloc3, but
that's ugly.
--
Summary: dl-tls.c: tls_get_addr, etc, allocate using
__libc_memalign but free with free - causes problems if
you link a different malloc/free/etc library
Product: glibc
Version: 2.3.4
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: cr at progress dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=9721
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.