libc: Extend __libc_freeres framework (Bug 23329).
commit2827ab990aefbb0e53374199b875d98f116d6390
authorCarlos O'Donell <carlos@redhat.com>
Fri, 22 Jun 2018 13:28:47 +0000 (22 09:28 -0400)
committerCarlos O'Donell <carlos@redhat.com>
Sat, 30 Jun 2018 02:39:06 +0000 (29 22:39 -0400)
tree0063b4c07be87d887d4a4893b9681b9e61479e8b
parent37d3d244e1a0ca7e7ac89b8e768e665adbb2e2d8
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 <dj@redhat.com>
Signed-off-by: Carlos O'Donell <carlos@redhat.com>
26 files changed:
ChangeLog
dlfcn/Makefile
dlfcn/Versions
dlfcn/dlerror.c
dlfcn/dlfreeres.c [new file with mode: 0644]
dlfcn/sdlfreeres.c [new file with mode: 0644]
include/dlfcn.h
include/libc-symbols.h
include/set-hooks.h
malloc/set-freeres.c
malloc/thread-freeres.c
nptl/Makefile
nptl/Versions
nptl/allocatestack.c
nptl/libc_pthread_init.c
nptl/nptl-init.c
nptl/nptlfreeres.c [new file with mode: 0644]
nptl/pthreadP.h
resolv/res-close.c
resolv/resolv_conf.c
string/strerror_l.c
sunrpc/rpc_thread.c
sysdeps/mach/strerror_l.c
sysdeps/nptl/pthread-functions.h
sysdeps/nptl/unwind-forcedunwind.c
sysdeps/unix/sysv/linux/shm-directory.c