From 2827ab990aefbb0e53374199b875d98f116d6390 Mon Sep 17 00:00:00 2001 From: Carlos O'Donell Date: Fri, 22 Jun 2018 09:28:47 -0400 Subject: libc: Extend __libc_freeres framework (Bug 23329). The __libc_freeres framework does not extend to non-libc.so objects. This causes problems in general for valgrind and mtrace detecting unfreed objects in both libdl.so and libpthread.so. This change is a pre-requisite to properly moving the malloc hooks out of malloc since such a move now requires precise accounting of all allocated data before destructors are run. This commit adds a proper hook in libc.so.6 for both libdl.so and for libpthread.so, this ensures that shm-directory.c which uses freeit () to free memory is called properly. We also remove the nptl_freeres hook and fall back to using weak-ref-and-check idiom for a loaded libpthread.so, thus making this process similar for all DSOs. Lastly we follow best practice and use explicit free calls for both libdl.so and libpthread.so instead of the generic hook process which has undefined order. Tested on x86_64 with no regressions. Signed-off-by: DJ Delorie Signed-off-by: Carlos O'Donell --- nptl/nptl-init.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'nptl/nptl-init.c') diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index 1d3790f..907411d 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -78,9 +78,6 @@ extern void __nptl_set_robust (struct pthread *); #ifdef SHARED -static void nptl_freeres (void); - - static const struct pthread_functions pthread_functions = { .ptr_pthread_attr_destroy = __pthread_attr_destroy, @@ -140,8 +137,6 @@ static const struct pthread_functions pthread_functions = # ifdef SIGSETXID .ptr__nptl_setxid = __nptl_setxid, # endif - /* For now only the stack cache needs to be freed. */ - .ptr_freeres = nptl_freeres, .ptr_set_robust = __nptl_set_robust }; # define ptr_pthread_functions &pthread_functions @@ -151,16 +146,6 @@ static const struct pthread_functions pthread_functions = #ifdef SHARED -/* This function is called indirectly from the freeres code in libc. */ -static void -__libc_freeres_fn_section -nptl_freeres (void) -{ - __unwind_freeres (); - __free_stacks (0); -} - - static #endif void -- cgit v1.1