From: Elias Naur Date: Sat, 25 Mar 2017 11:55:40 +0000 (+0100) Subject: runtime/cgo: raise the thread-local storage slot search limit on Android X-Git-Tag: go1.9beta1~964 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0476c7a7b50614f98f37a51ee2100af922288b68;p=gostls13.git runtime/cgo: raise the thread-local storage slot search limit on Android On Android, the thread local offset is found by looping through memory starting at the TLS base address. The search is limited to PTHREAD_KEYS_MAX, but issue 19472 made it clear that in some cases, the slot is located further from the TLS base. The limit is merely a sanity check in case our assumptions about the thread-local storage layout are wrong, so this CL raises it to 384, which is enough for the test case in issue 19472. Fixes #19472 Change-Id: I89d1db3e9739d3a7fff5548ae487a7483c0a278a Reviewed-on: https://go-review.googlesource.com/38636 Run-TryBot: Elias Naur TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- diff --git a/src/runtime/cgo/gcc_android_arm.c b/src/runtime/cgo/gcc_android_arm.c index c7b13f9a7f..d8936ea007 100644 --- a/src/runtime/cgo/gcc_android_arm.c +++ b/src/runtime/cgo/gcc_android_arm.c @@ -10,13 +10,6 @@ #define magic1 (0x23581321U) -// PTHREAD_KEYS_MAX has been added to sys/limits.h at head in bionic: -// https://android.googlesource.com/platform/bionic/+/master/libc/include/sys/limits.h -// TODO(crawshaw): remove this definition when NDK r10d is required. -#ifndef PTHREAD_KEYS_MAX -#define PTHREAD_KEYS_MAX 128 -#endif - // inittls allocates a thread-local storage slot for g. // // It finds the first available slot using pthread_key_create and uses @@ -32,7 +25,11 @@ inittls(void **tlsg, void **tlsbase) fatalf("pthread_key_create failed: %d", err); } pthread_setspecific(k, (void*)magic1); - for (i=0; i