Closed
Description
The following crash has started to appear when running Android apps with Go tip:
04-15 20:49:36.875 4033 4033 F DEBUG : #00 pc 00000000000a978c /data/app/com.example.BindTest.test-iyBWQdBs046wze2Z_WqATA==/lib/x86_64/libgojni.so (runtime.sigaction+108)
04-15 20:49:36.875 4033 4033 F DEBUG : #01 pc 00000000000e4432 /data/app/com.example.BindTest.test-iyBWQdBs046wze2Z_WqATA==/lib/x86_64/libgojni.so (runtime.initsig+146)
04-15 20:49:36.875 4033 4033 F DEBUG : #02 pc 00000000000ced96 /data/app/com.example.BindTest.test-iyBWQdBs046wze2Z_WqATA==/lib/x86_64/libgojni.so (runtime.libpreinit+22)
04-15 20:49:36.875 4033 4033 F DEBUG : #03 pc 00000000000fb32a /data/app/com.example.BindTest.test-iyBWQdBs046wze2Z_WqATA==/lib/x86_64/libgojni.so (_rt0_amd64_lib+74)
04-15 20:49:36.875 4033 4033 F DEBUG : #04 pc 0000000000025b4f /system/bin/linker64 (__dl__ZL10call_arrayIPFviPPcS1_EEvPKcPT_mbS5_+255)
04-15 20:49:36.875 4033 4033 F DEBUG : #05 pc 0000000000000000 <unknown>
I believe the crash is caused by an invalid g returned from getg
, called from sigaction
. At the time libpreinit
is called, TLS hasn't been set up yet (it is set up later in rt0_go
).
This started to appear after my fixes for #29674 but I believe it's been a latent bug for a long time. We've just been lucky that the static TLS slot previously used for accessing g on android/amd64 and android/386 always contained 0.
The cause is clear but the fix isn't obvious to me. Please advice, @cherrymui @ianlancetaylor .