about summary refs log tree commit diff
path: root/elf/dl-close.c
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2010-05-03 08:08:28 -0700
committerUlrich Drepper <drepper@redhat.com>2010-05-03 08:08:28 -0700
commit5a2a1d75043138e696222ced4560de2fb90b8024 (patch)
tree76c2da1388b8787ebabb9e61cf27d7510d1f5a7b /elf/dl-close.c
parentc739ec3d81a34a87d8ae1276eab4f5880afc3476 (diff)
downloadglibc-5a2a1d75043138e696222ced4560de2fb90b8024.tar.gz
glibc-5a2a1d75043138e696222ced4560de2fb90b8024.tar.xz
glibc-5a2a1d75043138e696222ced4560de2fb90b8024.zip
Don't deadlock in __dl_iterate_phdr while (un)loading objects.
Diffstat (limited to 'elf/dl-close.c')
-rw-r--r--elf/dl-close.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c
index b73a7adb1a..700e765c3c 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -507,6 +507,9 @@ _dl_close_worker (struct link_map *map)
   size_t tls_free_end;
   tls_free_start = tls_free_end = NO_TLS_OFFSET;
 
+  /* We modify the list of loaded objects.  */
+  __rtld_lock_lock_recursive (GL(dl_load_write_lock));
+
   /* Check each element of the search list to see if all references to
      it are gone.  */
   for (unsigned int i = first_loaded; i < nloaded; ++i)
@@ -665,6 +668,8 @@ _dl_close_worker (struct link_map *map)
 	}
     }
 
+  __rtld_lock_unlock_recursive (GL(dl_load_write_lock));
+
   /* If we removed any object which uses TLS bump the generation counter.  */
   if (any_tls)
     {