Remove PTHREAD_ATTR_FLAG_USER_ALLOCATED_STACK.
Patch for https://android-review.googlesource.com/#/c/120844/.
Change-Id: Idca5ccd7b28e8f07f1d2d1b6e3bba6781b62f0e0
diff --git a/libc/bionic/pthread_internals.cpp b/libc/bionic/pthread_internals.cpp
index a0a8df0..14061d1 100644
--- a/libc/bionic/pthread_internals.cpp
+++ b/libc/bionic/pthread_internals.cpp
@@ -51,11 +51,9 @@
g_thread_list = thread->next;
}
- // For threads using user allocated stack (including the main thread), the pthread_internal_t
- // can't be freed since it is on the stack.
- if (free_thread && !thread->user_allocated_stack()) {
- // Use one munmap to free allocated stack size, including thread stack and pthread_internal_t.
- munmap(thread->attr.stack_base, thread->allocated_stack_size);
+ if (free_thread && thread->mmap_size != 0) {
+ // Free mapped space, including thread stack and pthread_internal_t.
+ munmap(thread->attr.stack_base, thread->mmap_size);
}
}