mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
dlfcn: dlerror needs to call free from the base namespace [BZ #24773]
Calling free directly may end up freeing a pointer allocated by the dynamic loader using malloc from libc.so in the base namespace using the allocator from libc.so in a secondary namespace, which results in crashes. This commit redirects the free call through GLRO and the dynamic linker, to reach the correct namespace. It also cleans up the dlerror handling along the way, so that pthread_setspecific is no longer needed (which avoids triggering bug 24774).
This commit is contained in:
@ -30,6 +30,17 @@
|
||||
a pointer comparison. See below and in dlfcn/dlerror.c. */
|
||||
static const char _dl_out_of_memory[] = "out of memory";
|
||||
|
||||
/* Call free in the main libc.so. This allows other namespaces to
|
||||
free pointers on the main libc heap, via GLRO (dl_error_free). It
|
||||
also avoids calling free on the special, pre-allocated
|
||||
out-of-memory error message. */
|
||||
void
|
||||
_dl_error_free (void *ptr)
|
||||
{
|
||||
if (ptr != _dl_out_of_memory)
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
/* Dummy allocation object used if allocating the message buffer
|
||||
fails. */
|
||||
static void
|
||||
|
Reference in New Issue
Block a user