summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2018-04-27 06:00:54 +0100
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2018-04-27 22:47:05 +0100
commit14be0795f4ad0ec7c689cfdf9e891bce24241999 (patch)
tree8780cb224dfd993f5e83a7cd80bfefd0dcdb551e
parent132decd2a043d0ccf799f42bf89f3ae0c11e95d5 (diff)
libdl: first execute all destructors, then munmap library
Fix problem which might exist since 2011. We need to execute the destructors for all dependant libraries, before munmap the shared libraries, otherwise running destructor of a dependent library might cause a segfault, trying to access an already unmapped memory. This fixes for example segfaults while running php -m with ldap module. Reported-By: Dave Flogeras <dflogeras2@gmail.com> Tested-By: Dave Flogeras <dflogeras2@gmail.com>
-rw-r--r--ldso/libdl/libdl.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 213eba49f..ac0acd504 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -849,7 +849,12 @@ static int do_dlclose(void *vhandle, int need_fini)
DL_CALL_FUNC_AT_ADDR (dl_elf_fini, tpnt->loadaddr, (int (*)(void)));
}
}
+ }
+ }
+ for (j = 0; j < handle->init_fini.nlist; ++j) {
+ tpnt = handle->init_fini.init_fini[j];
+ if (tpnt->usage_count == 0) {
_dl_if_debug_print("unmapping: %s\n", tpnt->libname);
end = 0;
for (i = 0, ppnt = tpnt->ppnt;