Revert "Use mmap to create the pthread_internal_t."

Unfortunately, this change provokes random crashes for ART, and
I have seen libc crashes on the device that might be related to it.

Reverting it fixes the ART crashes. there is unfortunately no
stack trace for the crashes, but just a "Segmentation fault" message.


This reverts commit cc5f6543e3.

Change-Id: I68dca8e1e9b9edcce7eb84596e8db619e40e8052
This commit is contained in:
Nicolas Geoffray
2014-11-26 11:53:44 +00:00
parent cc5f6543e3
commit 5b8ceff5f8
4 changed files with 11 additions and 34 deletions

View File

@@ -158,8 +158,9 @@ int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr,
// Inform the rest of the C library that at least one thread was created.
__isthreaded = 1;
pthread_internal_t* thread = __create_thread_struct();
pthread_internal_t* thread = reinterpret_cast<pthread_internal_t*>(calloc(sizeof(*thread), 1));
if (thread == NULL) {
__libc_format_log(ANDROID_LOG_WARN, "libc", "pthread_create failed: couldn't allocate thread");
return EAGAIN;
}
@@ -178,7 +179,7 @@ int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr,
// The caller didn't provide a stack, so allocate one.
thread->attr.stack_base = __create_thread_stack(thread);
if (thread->attr.stack_base == NULL) {
__free_thread_struct(thread);
free(thread);
return EAGAIN;
}
} else {
@@ -229,7 +230,7 @@ int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr,
if (!thread->user_allocated_stack()) {
munmap(thread->attr.stack_base, thread->attr.stack_size);
}
__free_thread_struct(thread);
free(thread);
__libc_format_log(ANDROID_LOG_WARN, "libc", "pthread_create failed: clone failed: %s", strerror(errno));
return clone_errno;
}