OSDN Git Service

Allocate thread local buffers in __init_tls.
authorJosh Gao <jmgao@google.com>
Wed, 22 Feb 2017 20:19:05 +0000 (12:19 -0800)
committerJosh Gao <jmgao@google.com>
Thu, 23 Feb 2017 00:05:03 +0000 (16:05 -0800)
commit5e2285d3ccdbb64a49ad2e5e521f50c897a3954d
treecd56c251f1710652fad3b84121248a12071b42e0
parentc9a840ac76c7cdbe6028ac91cdb8eb6698f0a854
Allocate thread local buffers in __init_tls.

Thread local buffers were using pthread_setspecific for storage with
lazy initialization. pthread_setspecific shares TLS slots between the
linker and libc.so, so thread local buffers being initialized in a
different order between libc.so and the linker meant that bad things
would happen (manifesting as snprintf not working because the
locale was mangled)

Bug: http://b/20464031
Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests
      everything passes
Test: /data/nativetest/bionic-unit-tests/bionic-unit-tests
      thread_local tests are failing both before and after (KUSER_HELPERS?)
Test: /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
      no additional failures
Change-Id: I9f445a77c6e86979f3fa49c4a5feecf6ec2b0c3f
13 files changed:
libc/bionic/grp_pwd.cpp
libc/bionic/libgen.cpp
libc/bionic/locale.cpp
libc/bionic/mntent.cpp
libc/bionic/pthread_create.cpp
libc/bionic/pthread_internal.cpp
libc/bionic/pthread_internal.h
libc/bionic/pty.cpp
libc/bionic/strerror.cpp
libc/bionic/strsignal.cpp
libc/private/bionic_tls.h
libc/private/grp_pwd.h [moved from libc/private/ThreadLocalBuffer.h with 60% similarity]
linker/dlfcn.cpp