golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.25k stars 17.7k forks source link

x/mobile: go mobile bind, SIGSYS crash on older Android versions #70495

Open Beerosagos opened 3 days ago

Beerosagos commented 3 days ago

Go version

go version go1.23.2 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/opt/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/opt/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/go_dist/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/go_dist/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.2'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/opt/go/src/github.com/BitBoxSwiss/bitbox-wallet-app/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2246426898=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Built an Android app that includes a go module compiled with

gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target android -androidapi 21 .

And included it with a build.gradle dependency:

dependencies {
    [...]
    implementation project(path: ':myGoModule')
}

using

    compileSdk 34
    minSdkVersion 21
    targetSdkVersion 34

What did you see happen?

Since our last upgrade to go1.23, the compiled Android app crashes at startup on older Android versions (tested 9.0 and 10.0, i.e. API 28 and 29 on Android studio emulator) with the following error:

2024-11-21 15:13:36.524 17389-17472 GoLog                   ch.shiftcrypto.bitboxapp.debug       E  [WARNING:viz_main_impl.cc(85)] VizNullHypothesis is disabled (not a warning)
2024-11-21 15:13:36.780 17389-17472 GoLog                   ch.shiftcrypto.bitboxapp.debug       E  [1121/151336.779929:ERROR:elf_dynamic_array_reader.h(64)] tag not found
2024-11-21 15:13:36.796 17389-17470 libc                    ch.shiftcrypto.bitboxapp.debug       A  Fatal signal 31 (SIGSYS), code 1 (SYS_SECCOMP) in tid 17470 (bitboxapp.debug), pid 17389 (bitboxapp.debug)
2024-11-21 15:13:36.829 17489-17489 DEBUG                   pid-17489                            A  pid: 17389, tid: 17470, name: bitboxapp.debug  >>> ch.shiftcrypto.bitboxapp.debug <<<
2024-11-21 15:13:36.829 17489-17489 DEBUG                   pid-17489                            A      #00 pc 00124bee  /data/app/ch.shiftcrypto.bitboxapp.debug-E5gwW0mWuw-zSOShuc4uzA==/lib/x86/libgojni.so

Everything works fine for newer Android versions (e.g. 13.0).

Upgrading to Go 1.23.3 doesn't solve the issue, but reverting to Go 1.22.4 does, on all the Android versions tested.

What did you expect to see?

The app should not crash on startup.

gabyhelp commented 3 days ago

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

dmitshur commented 3 days ago

CC @hajimehoshi.

hajimehoshi commented 3 days ago

I have no idea. Isn't this a compiler issue?

ianlancetaylor commented 2 days ago

See #70508.