From: Yabin Cui Date: Wed, 25 Mar 2015 23:18:21 +0000 (-0700) Subject: Fix in error handling in pthread_create.cpp. X-Git-Tag: android-x86-7.1-r1~757^2~147^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=799cb35f45a161de96b272de38724f77e988f5f3;p=android-x86%2Fbionic.git Fix in error handling in pthread_create.cpp. It is due to a previous change "Let g_thread_list_lock only protect g_thread_list". We need to add the newly created thread to thread_list even if __init_thread fails, so the thread can exit successfully. Change-Id: I0332df11acfdd181350bcc092b12d90d679057a4 --- diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp index 3d73d52e5..66632c494 100644 --- a/libc/bionic/pthread_create.cpp +++ b/libc/bionic/pthread_create.cpp @@ -267,6 +267,7 @@ int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr, // Mark the thread detached and replace its start_routine with a no-op. // Letting the thread run is the easiest way to clean up its resources. atomic_store(&thread->join_state, THREAD_DETACHED); + __pthread_internal_add(thread); thread->start_routine = __do_nothing; pthread_mutex_unlock(&thread->startup_handshake_mutex); return init_errno;