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, runtime: libgojni.so crashes on ARM64 devices for methods defined in Go code #65057

Closed ImagineYao closed 9 months ago

ImagineYao commented 10 months ago

Go version

go version go1.21.1 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/user/Library/Caches/go-build'
GOENV='/Users/user/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/user/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/user/go'
GOPRIVATE='*.okg.com'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go/bin'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN=''
GOTOOLDIR='/usr/local/go/bin/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/tg/6zv0sgfd1wl_f7h6_mf1clnm0000gn/T/go-build1079424989=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I use gomobile to package go project to aar. gomobile bind -v -target=android/arm64,android/arm when i call method defined in go project, it crashed on arm64 devices occasionally.

What did you see happen?

crashed occasionally, following is the dmp

Thread 97 (crashed)
 0  libgojni.so + 0x711d58
     x0 = 0x0000000000000000    x1 = 0x0000000000002e9e
     x2 = 0x0000000000000006    x3 = 0x0000000000000008
     x4 = 0x0000000000000001    x5 = 0xffffffffffffffff
     x6 = 0x00000077d85281f8    x7 = 0x000000000000000a
     x8 = 0x0000000000000083    x9 = 0x0000000000000031
    x10 = 0x000000000000000e   x11 = 0x00000077d8f691ce
    x12 = 0x0000000000000000   x13 = 0x0000000000000000
    x14 = 0x000000000000000e   x15 = 0x000000000000000b
    x16 = 0x00000078dcb14d80   x17 = 0x00000078dcc0ad60
    x18 = 0x0000007771f4a000   x19 = 0x0000000000001f9b
    x20 = 0x00000078dcc0ac00   x21 = 0x0000004000c6f400
    x22 = 0x0000000014c788c8   x23 = 0x000000007083e358
    x24 = 0x0000000012dc3a20   x25 = 0x0000000012dc39f8
    x26 = 0x00000078dcc0b578   x27 = 0x0000000000000000
    x28 = 0x0000004000ad0340    fp = 0x00000078dcc0b5f8
     lr = 0x00000077d85f8574    sp = 0x00000078dcc0b600
     pc = 0x00000077d8615d58
    Found by: given as instruction pointer in context
 1  libgojni.so + 0x6f4570
     fp = 0x00000078dcc0b618    lr = 0x00000077d85e156c
     sp = 0x00000078dcc0b608    pc = 0x00000077d85f8574
    Found by: previous frame's frame pointer
 2  libgojni.so + 0x6dd568
     fp = 0x00000078dcc0ba98    lr = 0x00000077d861286c
     sp = 0x00000078dcc0b628    pc = 0x00000077d85e156c
    Found by: previous frame's frame pointer
 3  libgojni.so + 0x70e868
     fp = 0x0000000000000000    lr = 0x6fbfeb8800000000
     sp = 0x00000078dcc0baa8    pc = 0x00000077d861286c
    Found by: previous frame's frame pointer

and the corresponding line is following

➜  arm64-v8a addr2line -f -C -e libgojni.so 0x711d58
runtime.raise.abi0
/usr/local/go/src/runtime/sys_linux_arm64.s:158
➜  arm64-v8a addr2line -f -C -e libgojni.so 0x6f4570
runtime.dieFromSignal
/usr/local/go/src/runtime/signal_unix.go:903
➜  arm64-v8a addr2line -f -C -e libgojni.so 0x6dd568
runtime.crash
/usr/local/go/src/runtime/signal_unix.go:985
➜  arm64-v8a addr2line -f -C -e libgojni.so 0x70e868
runtime.systemstack.abi0
/usr/local/go/src/runtime/asm_arm64.s:243

What did you expect to see?

it should not be crashed

odeke-em commented 10 months ago

Thank you for this report @ImagineYao! It would be helpful to produce some sort of reproduction that would make this Github issue more actionable and can be easily investigated. In the meantime I shall kindly cc some runtime and gomobile folks @cherrymui @hyangah

ImagineYao commented 10 months ago

hello, any idea about this? @cherrymui @hyangah

cherrymui commented 10 months ago

As @odeke-em mentioned above, could you share a way to reproduce the issue? Also, could you try the latest release, Go 1.21.6, or Go 1.22rc1? Thanks.

gopherbot commented 9 months ago

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

Skilledconsultant commented 4 months ago

@ImagineYao Yao Yinman Does any solution for this problem? I got same error and crashed my app