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/mobile,runtime: missing stack trace on Android crash #69101

Open
xcolwell opened this issue Aug 28, 2024 · 3 comments
Open

x/mobile,runtime: missing stack trace on Android crash #69101

xcolwell opened this issue Aug 28, 2024 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. help wanted mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@xcolwell
Copy link

Go version

go version go1.22.6 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/brien/Library/Caches/go-build'
GOENV='/Users/brien/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/brien/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/brien/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.6'
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/r3/v_3z60rx2cxg0s1r9tl9fbmw0000gn/T/go-build4289722356=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Create a go module and build it with gomobile. For example, the build command below will produce an AAR file that can be bundled into an Android app.

cd /path/to/my/package
gomobile bind \
		-target=android/arm64 -androidapi 24 \
		-javapkg my.package \
		-trimpath \
		-gcflags="-dwarf=true" \
		-ldflags="-compressdwarf=false -B gobuildid" \
		-o build/android/MyPackage.aar \
	package/name

The build AAR can be bundled into an Android app with the build.gradle lines:

dependencies {
    compileOnly fileTree(dir: "/path/to/my/package/build/android", include: ['*-sources.jar'])
    implementation fileTree(dir: "/path/to/my/package/build/android", include: ['*.aar', '*.jar'])
}

What did you see happen?

Now if there is a crash from a goroutine inside the library, the following is printed to the Android logs. e.g. a nil pointer deference

2024-08-27 22:33:02.495 22477-22547 AndroidClassName                  my.package                I  init
2024-08-27 22:33:02.497 22477-0     Go                      my.package                E  panic: runtime error: invalid memory address or nil pointer dereference
--------- beginning of crash
2024-08-27 22:33:02.497 22477-0     Go                      my.package                E  [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x6f9cee6a0c]
2024-08-27 22:33:02.497 22477-22537 libc                    my.package                A  Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 22537 (y.package), pid 22477 (y.package)

What did you expect to see?

I would expect to see a full stack trace similar to what happens when a go binary crashes. This is much more useful for crash logging and debugging.

@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Aug 28, 2024
@gopherbot gopherbot added this to the Unreleased milestone Aug 28, 2024
@github-staff github-staff deleted a comment Aug 28, 2024
@prattmic
Copy link
Member

cc @hyangah

@prattmic prattmic changed the title x/mobile: missing stack trace on Android crash x/mobile,runtime: missing stack trace on Android crash Aug 28, 2024
@prattmic prattmic added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. compiler/runtime Issues related to the Go compiler and/or runtime. labels Aug 28, 2024
@prattmic prattmic modified the milestones: Unreleased, Backlog Aug 28, 2024
@prattmic
Copy link
Member

cc @golang/runtime @golang/android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. help wanted mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

No branches or pull requests

5 participants