aboutsummaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2014-08-06 14:15:01 -0700
committerChristopher Ferris <cferris@google.com>2014-08-06 17:57:04 -0700
commite380960813bbb6e05d820eb75885556a1c4bf6ac (patch)
tree9eafb0466f8e3cdc3c24125d295e488312ac2099 /libc
parentf3868fa735ad67ec853f3db36936ca184bd5f79a (diff)
downloadandroid_bionic-e380960813bbb6e05d820eb75885556a1c4bf6ac.tar.gz
android_bionic-e380960813bbb6e05d820eb75885556a1c4bf6ac.tar.bz2
android_bionic-e380960813bbb6e05d820eb75885556a1c4bf6ac.zip
Do a second key cleanup in pthread_exit.
During pthread_exit, the keys are cleaned. Unfortunately, a call to free occurs after the cleanup and the memory for some of the keys is recreated when using jemalloc. The solution is to do the key cleanup twice. Also, modify the pthread_detach__leak test to be less flaky when run on a jemalloc system. Bug: 16513133 (cherry picked from commit 18d93f2793fad393b6aa6eae6afe1054958339d5) Change-Id: Idb32e7f9b09e2c088d256ed9eb881df80c81ff8e
Diffstat (limited to 'libc')
-rw-r--r--libc/bionic/pthread_exit.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/libc/bionic/pthread_exit.cpp b/libc/bionic/pthread_exit.cpp
index a6bb36312..6cd5311ed 100644
--- a/libc/bionic/pthread_exit.cpp
+++ b/libc/bionic/pthread_exit.cpp
@@ -112,6 +112,12 @@ void pthread_exit(void* return_value) {
}
pthread_mutex_unlock(&g_thread_list_lock);
+ // Perform a second key cleanup. When using jemalloc, a call to free from
+ // _pthread_internal_remove_locked causes the memory associated with a key
+ // to be reallocated.
+ // TODO: When b/16847284 is fixed this call can be removed.
+ pthread_key_clean_all();
+
if (user_allocated_stack) {
// Cleaning up this thread's stack is the creator's responsibility, not ours.
__exit(0);