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

runtime: fatal error: failed to get system page size / panic before malloc heap initialized #18041

Closed
steeve opened this issue Nov 24, 2016 · 15 comments

Comments

Projects
None yet
5 participants
@steeve
Copy link
Contributor

commented Nov 24, 2016

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version devel +8ace346 Wed Nov 23 01:16:47 2016 +0000 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/steeve/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/HEAD-8ace346/libexec"
GOTOOLDIR="/usr/local/Cellar/go/HEAD-8ace346/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/go-build321427714=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

Build a gomobile library for Android, link it, and try to launch the app and use the library.

What did you expect to see?

The app launching.

What did you see instead?

fatal error: failed to get system page size
runtime: panic before malloc heap initialized
runtime stack:
runtime.throw(0x7f75837534, 0x1e)
    /usr/local/Cellar/go/HEAD-8ace346/libexec/src/runtime/panic.go:596 +0x70 fp=0x7f74fe2300 sp=0x7f74fe22e0
runtime.mallocinit()
    /usr/local/Cellar/go/HEAD-8ace346/libexec/src/runtime/malloc.go:223 +0x46c fp=0x7f74fe23a0 sp=0x7f74fe2300
runtime.schedinit()
    /usr/local/Cellar/go/HEAD-8ace346/libexec/src/runtime/proc.go:465 +0x38 fp=0x7f74fe23e0 sp=0x7f74fe23a0
runtime.rt0_go(0x7f8fa36d48, 0x7f8ff012c0, 0x4f14, 0x0, 0x0, 0x7f75f3f440, 0x0, 0x4f1400004f26, 0x0, 0x7f74ee5000, ...)
    /usr/local/Cellar/go/HEAD-8ace346/libexec/src/runtime/asm_arm64.s:70 +0xbc fp=0x7f74fe2410 sp=0x7f74fe23e0
@minux

This comment has been minimized.

Copy link
Member

commented Nov 24, 2016

@quentinmit quentinmit added the NeedsFix label Nov 24, 2016

@quentinmit quentinmit added this to the Go1.8 milestone Nov 24, 2016

@steeve

This comment has been minimized.

Copy link
Contributor Author

commented Nov 25, 2016

Also, if this was not clear, the bug happens on android/arm arm64. Works fine on darwin/arm64. Haven't tested linux/arm64 too.

Seems to be linked to https://go-review.googlesource.com/#/c/25022/.

@minux

This comment has been minimized.

Copy link
Member

commented Nov 25, 2016

@aclements

This comment has been minimized.

Copy link
Member

commented Nov 28, 2016

It seems we need to have a fallback method (read /proc/self/auxv?)
to get the physical page size in runtime/os_linux.go?

Yes, we probably need something like that, but since this is GOOS=android, os_linux.go isn't involved right now. As far as I can tell, Android isn't even trying to set the physical page size. I'm not very familiar with the Android runtime init process, which is quite different from other OSes, so I'm trying to work out where to put this setup now.

@aclements

This comment has been minimized.

Copy link
Member

commented Nov 28, 2016

I'm not very familiar with the Android runtime init process

Okay, for example, I did not understand the GOOS=android apparently implies the linux build tag, so os_linux.go is involved. But I think rt0_android_*.go is synthesizing an empty auxv.

@gopherbot

This comment has been minimized.

Copy link

commented Nov 28, 2016

CL https://golang.org/cl/33651 mentions this issue.

@gopherbot

This comment has been minimized.

Copy link

commented Nov 28, 2016

CL https://golang.org/cl/33652 mentions this issue.

gopherbot pushed a commit that referenced this issue Nov 29, 2016

runtime: extract Linux auxv handling
This refactoring is in preparation for handling auxv differently in
Android shared libraries.

Updates #18041.

Change-Id: If0458a309f9c804e7abd0a58b5a224d89f8da257
Reviewed-on: https://go-review.googlesource.com/33651
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>

@gopherbot gopherbot closed this in 6f287fa Nov 29, 2016

@steeve

This comment has been minimized.

Copy link
Contributor Author

commented Dec 19, 2016

FYI, this is still an issue in go 1.8b2, and is not happening on 1.7.
While 6f287fa fixes the issue in debug mode apps, release mode apps fail because /proc/self/auxv because of denied permissions.

This is the same issue as #9229

@minux minux reopened this Dec 19, 2016

@minux

This comment has been minimized.

Copy link
Member

commented Dec 19, 2016

@steeve

This comment has been minimized.

Copy link
Contributor Author

commented Dec 19, 2016

I would advize against that since using getauxval requires 21+.
That means dropping almost 37% of the Android user base, according to https://developer.android.com/about/dashboards/index.html

Could falling back to auvx generation (like it used to) as a last resort be an option ?

We ourselves release on 16+.

@quentinmit

This comment has been minimized.

Copy link
Contributor

commented Dec 19, 2016

@minux

This comment has been minimized.

Copy link
Member

commented Dec 19, 2016

@gopherbot

This comment has been minimized.

Copy link

commented Dec 19, 2016

CL https://golang.org/cl/34610 mentions this issue.

@minux

This comment has been minimized.

Copy link
Member

commented Dec 19, 2016

@gopherbot gopherbot closed this in a0667be Dec 19, 2016

@steeve

This comment has been minimized.

Copy link
Contributor Author

commented Dec 22, 2016

@minux sorry for the lag.
Just tested it with 860c9c0 and i can confirm it works fine.
Thank you all, that was super fast!

@golang golang locked and limited conversation to collaborators Dec 22, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.