OSDN Git Service

Don't corrupt the thread list if the main thread exits.
authorElliott Hughes <enh@google.com>
Thu, 1 Nov 2012 23:33:29 +0000 (16:33 -0700)
committerElliott Hughes <enh@google.com>
Fri, 2 Nov 2012 00:27:07 +0000 (17:27 -0700)
commit4f251bee5d51228217c1bf4dfc9219f3058bd3ed
tree3d0f1faef6a38e494f8157e467e7fc0f876f6cd4
parent064f862d557ab741575dfae479499a07ca0ab742
Don't corrupt the thread list if the main thread exits.

...and don't pass a non-heap pointer to free(3), either.

This patch replaces the "node** prev" with the clearer "node* prev"
style and fixes the null pointer dereference in the old code. That's
not sufficient to fix the reporter's bug, though. The pthread_internal_t*
for the main thread isn't heap-allocated --- __libc_init_tls causes a
pointer to a statically-allocated pthread_internal_t to be added to
the thread list.

Bug: http://code.google.com/p/android/issues/detail?id=37410
Change-Id: I112b7f22782fc789d58f9c783f7b323bda8fb8b7
libc/bionic/libc_init_common.c
libc/bionic/pthread.c
libc/bionic/pthread_internal.h
tests/pthread_test.cpp