mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +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:
@@ -16,6 +16,7 @@
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <dlfcn/dlerror.h>
|
||||
#include <libc-internal.h>
|
||||
#include <malloc-internal.h>
|
||||
#include <resolv/resolv-internal.h>
|
||||
@@ -36,6 +37,7 @@ __libc_thread_freeres (void)
|
||||
#endif
|
||||
call_function_static_weak (__res_thread_freeres);
|
||||
__glibc_tls_internal_free ();
|
||||
call_function_static_weak (__libc_dlerror_result_free);
|
||||
|
||||
/* This should come last because it shuts down malloc for this
|
||||
thread and the other shutdown functions might well call free. */
|
||||
|
Reference in New Issue
Block a user