Skip to content
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

x/sys/cpu: Crash on android arm64 device in release build #36622

Closed
fbzhong opened this issue Jan 17, 2020 · 3 comments
Closed

x/sys/cpu: Crash on android arm64 device in release build #36622

fbzhong opened this issue Jan 17, 2020 · 3 comments

Comments

@fbzhong
Copy link

fbzhong commented Jan 17, 2020

$ go version
go version go1.13.6 darwin/amd64
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/zzzzz/Library/Caches/go-build"
GOENV="/Users/zzzzz/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/usr/local/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/opt/go/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/zzzzz/Downloads/golang_sys_crash/golib/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_7/2sw8zmxd5jdd2f1shskh380m0000gn/T/go-build136262396=/tmp/go-build -gno-record-gcc-switches -fno-common"
$ gomobile version
gomobile version +875e90d Wed Jan 15 17:48:49 2020 +0000 (android,ios); androidSDK=/usr/local/Android/sdk/platforms/android-29

Android NDK: 21.0.6113669
Android SDK: 29.0.2
Android Studio: 3.5.3

I have an android app that depends on golang.org/x/sys library. When I upgrade from `golang.org/x/sys' package from golang/sys@6d18c01 to next commit golang/sys@85b82a3 , my android app building in release mode was crashed on my device. I tried Pixel 2 + Android Q, Pixel 4 XL + Android Q and Redmi 6 Pro + Android Pie.

I reproduce this crash and sample code is at https://github.com/fbzhong/SysCrashDemo (including golang lib & Android app). Only one line in the golib:

import (
	"golang.org/x/sys/cpu"
)

func Init(appName, appVersion string) bool {
	return cpu.Initialized
}

Running release APK on device is crashed on my device, debug APK works well. And the last good commit is golang/sys@6d18c01 , the first crash commit is golang/sys@85b82a3 .The following is a crash log:

2020-01-17 17:11:31.963 22689-22689/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2020-01-17 17:11:31.963 22689-22689/? A/DEBUG: Build fingerprint: 'google/walleye/walleye:10/QQ1A.191205.008/5974827:user/release-keys'
2020-01-17 17:11:31.963 22689-22689/? A/DEBUG: Revision: 'MP1'
2020-01-17 17:11:31.963 22689-22689/? A/DEBUG: ABI: 'arm64'
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG: Timestamp: 2020-01-17 17:11:31+0800
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG: pid: 22639, tid: 22682, name: sample.syscrash  >>> com.github.fbzhong.sample.syscrash <<<
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG: uid: 10182
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG: signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 0x70f1b7a4a0 (*pc=0xd5380600)
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG:     x0  0000000000000001  x1  00000070f1cbb800  x2  000000400004be60  x3  0000000000000000
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG:     x4  00000070f1c10f20  x5  0000000000000000  x6  0000000000000030  x7  0000000000001000
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG:     x8  0000000000000006  x9  00000000000000f9  x10 000000400008417f  x11 0000000000001000
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG:     x12 0000000000000001  x13 00000070f1bb3907  x14 0000000000000000  x15 00000000000000f9
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG:     x16 0000000000000000  x17 0000000000000000  x18 00000070f127a000  x19 0000000000000006
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG:     x20 000000400004bd10  x21 00000070f1ca0dc0  x22 00000070f1cbbe54  x23 00000070f1cbbe55
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG:     x24 00000070f1c9ffe0  x25 0000000000000018  x26 00000070f1c93cc8  x27 ffffffffffffffb3
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG:     x28 0000004000000180  x29 0000000000000000
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG:     sp  000000400004be40  lr  00000070f1b79d88  pc  00000070f1b7a4a0
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG: backtrace:
2020-01-17 17:11:31.964 22689-22689/? A/DEBUG:       #00 pc 00000000000fa4a0  /data/app/com.github.fbzhong.sample.syscrash-xyOd8b5nMJGIlZFpFS8nAA==/lib/arm64/libgojni.so

Sorry I didn't take more time to find out which line of code caused this crash, hope someone could fix this soon.

@gopherbot gopherbot added this to the Unreleased milestone Jan 17, 2020
@tklauser
Copy link
Member

Seems like android doesn't allow reading the ARM64 instruction set attribute and processor feature registers in all cases. Will send a fix.

@gopherbot
Copy link

Change https://golang.org/cl/215237 mentions this issue: cpu: don't read ARM64 registers on Android

@fbzhong
Copy link
Author

fbzhong commented Jan 17, 2020

Great, it work well!

mergify bot pushed a commit to celo-org/celo-blockchain that referenced this issue May 22, 2020
### Description

This issue golang/go#36622 started causing crashes for us. Tested the fix with a new android build and it does not crash any more
@golang golang locked and limited conversation to collaborators Jan 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants