-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime/cgo: Crashing on Android Nougat due to value of PTHREAD_KEYS_MAX #19472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Milestone
Comments
Can you verify that https://go-review.googlesource.com/c/38636/ fixes your test case? If possible, please test both arm64 and arm. |
CL https://golang.org/cl/38636 mentions this issue. |
@eliasnaur I can confirm the new arm version is working. However, given that Unity only supports armv7, I haven't been able to test arm64 |
bytex64
pushed a commit
to SpiderOak/go
that referenced
this issue
Jul 12, 2017
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 golang#19472 Change-Id: I89d1db3e9739d3a7fff5548ae487a7483c0a278a Reviewed-on: https://go-review.googlesource.com/38636 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8 darwin/amd64
(Note that the actual crash occurs on Android 7.0 and higher)
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/rayvbr/Dropbox/Development/Go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/k7/jx2bs5q170z4lvdzbsdt426r0000gn/T/go-build687164964=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
What did you expect to see?
"This is a log" being printed to console
On Android versions lower than 7.0 this works.
On Android 7.0 without using Unity, it works as well
It is only the combination of Unity and Android 7.0 and up that causes the issue below.
What did you see instead?
Crash with 'could not find pthread key'.
03-02 09:26:39.279 14186-14186/? A/DEBUG: Revision: '8'
03-02 09:26:39.279 14186-14186/? A/DEBUG: ABI: 'arm'
03-02 09:26:39.279 14186-14186/? A/DEBUG: pid: 14049, tid: 14185, name: Thread-18 >>> com.xxx.yyy <<<
03-02 09:26:39.279 14186-14186/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
03-02 09:26:39.289 14186-14186/? A/DEBUG: Abort message: 'could not find pthread key'
03-02 09:26:39.289 14186-14186/? A/DEBUG: r0 00000000 r1 00003769 r2 00000006 r3 0000000
03-02 09:26:39.289 14186-14186/? A/DEBUG: r4 b32fe978 r5 00000006 r6 b32fe920 r7 0000010c
03-02 09:26:39.289 14186-14186/? A/DEBUG: r8 b2ae47f0 r9 00000000 sl b2ae4280 fp b32fe82c
03-02 09:26:39.289 14186-14186/? A/DEBUG: ip 00000000 sp b32fe7a8 lr e72d995 pc e72dc1c0 cpsr 600f0010
03-02 09:26:39.303 14186-14186/? A/DEBUG: backtrace:
03-02 09:26:39.303 14186-14186/? A/DEBUG: #00 pc 0004a1c0 /system/lib/libc.so (tgkill+12)
03-02 09:26:39.304 14186-14186/? A/DEBUG: #1 pc 00047953 /system/lib/libc.so (pthread_kill+34)
03-02 09:26:39.304 14186-14186/? A/DEBUG: #2 pc 0001d955 /system/lib/libc.so (raise+10)
03-02 09:26:39.304 14186-14186/? A/DEBUG: #3 pc 000194a1 /system/lib/libc.so (__libc_android_abort+34)
03-02 09:26:39.304 14186-14186/? A/DEBUG: #4 pc 000170e8 /system/lib/libc.so (abort+4)
03-02 09:26:39.304 14186-14186/? A/DEBUG: #5 pc 003f724c /data/app/com.xxx.yyy/lib/arm/libgojni.so (fatalf+212)
03-02 09:26:41.179 3245-3245/? E/audit: type=1701 audit(1488443201.174:997): auid=4294967295 uid=10260 gid=10260 ses=4294967295 subj=u:r:untrusted_app:s0:c512,c768 pid=14185 comm="Thread-18" exe="/system/bin/app_process32" sig=6`
Possible solution
Setting PTHREAD_KEYS_MAX in src/runtime/cgo/gcc_android_arm.c to 384 instead of 128 (and removing the surrounding #ifndef), seems to resolve the issue
The text was updated successfully, but these errors were encountered: