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: out of memory on iOS 7 #21288

Open
petraalm opened this Issue Aug 3, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@petraalm

petraalm commented Aug 3, 2017

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

go1.8.3 darwin/amd64

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

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOROOT="/usr/local/Cellar/go/1.8.3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.8.3/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/52/mr1qwqwd2mz8cq81554hx9nw0000gp/T/go-build953090659=/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?

Run my app with linked go framework on iOS 7 and it crashed.

What did you expect to see?

I expected app not to crash, since it works fine on iOS 8, iOS 9 and iOS 10.

What did you see instead?

runtime: out of memory: cannot allocate 65536-byte block (0 in use)
fatal error: out of memory

runtime stack:
runtime.throw(0xca768b, 0xd)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/panic.go:596 +0x78 fp=0x3942e5c sp=0x3942e50
runtime.(*mcache).refill(0x13b46000, 0x10, 0xe870e8)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/mcache.go:124 +0x100 fp=0x3942e70 sp=0x3942e5c
runtime.(*mcache).nextFree.func1()
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/malloc.go:526 +0x24 fp=0x3942e80 sp=0x3942e70
runtime.systemstack(0x3942ea4)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_arm.s:278 +0xb4 fp=0x3942e84 sp=0x3942e80
runtime.(*mcache).nextFree(0x13b46000, 0x13b46010, 0x81ff50, 0xe78858, 0x831d10)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/malloc.go:527 +0xa0 fp=0x3942eb0 sp=0x3942e84
runtime.mallocgc(0xf0, 0xc9f808, 0x849801, 0x3944000)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/malloc.go:679 +0x918 fp=0x3942f08 sp=0x3942eb0
runtime.newobject(0xc9f808, 0xe75ac0)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/malloc.go:808 +0x2c fp=0x3942f1c sp=0x3942f08
runtime.malg(0x8000, 0x2710)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/proc.go:2821 +0x20 fp=0x3942f38 sp=0x3942f1c
runtime.mpreinit(0xe76048)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/os_darwin.go:172 +0x1c fp=0x3942f44 sp=0x3942f38
runtime.mcommoninit(0xe76048)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/proc.go:540 +0xa4 fp=0x3942f5c sp=0x3942f44
runtime.schedinit()
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/proc.go:476 +0x44 fp=0x3942f78 sp=0x3942f5c
runtime.rt0_go(0x1, 0x27d1fcf8, 0x3968388b, 0x1, 0x0, 0x0, 0x80000, 0x0, 0x0, 0x0, ...)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_arm.s:61 +0x8c fp=0x3942fb8 sp=0x3942f78

I get this crash on the first run only, but on each subsequent run after that, app runs for a liitle bit, then crashes randomly with error: malloc: *** mach_vm_map(size=8388608) failed (error code=3) *** error: can't allocate region securely.

Interestingly enough, this happens even if the framework is not imported nor used anywhere in the code, it's just linked in the app. On newer versions of iOS it works well.

@gopherbot gopherbot added this to the Unreleased milestone Aug 3, 2017

@gopherbot gopherbot added the mobile label Aug 3, 2017

@petraalm

This comment has been minimized.

petraalm commented Aug 8, 2017

Gomobile uses this issue tracker, you just need to set the x/mobile tag.
Regarding the framework, apologies if I was unclear, I was refering to my own code written in Go, which was then exported to an iOS framework with gomobile build, just like it says in docs.

@eliasnaur

This comment has been minimized.

Contributor

eliasnaur commented Mar 14, 2018

If you're feeling adventurous, the current Go tip (to become 1.11) has improved its memory allocation strategy using sparse heap mappings. It would be interested to know if your problem persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment