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

Got "Cannot allocate memory" in Go 1.8, after strip app, run successfully. #19983

Closed
subchen opened this issue Apr 15, 2017 · 7 comments
Closed

Comments

@subchen
Copy link

subchen commented Apr 15, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8 darwin/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/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/rm/pwgcqbl91wl2kj768xl2967h0000gn/T/go-build524964552=/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?

I upgrade my mac from 10.10 (Yosemite) to 10.12.1 (macOS Sierra).

Then I cannot run binary which go build outputted, and no errors found in /var/log/system.log.
But after I strip it, I can run it successfully.

Note:

  1. I can run my project before I upgraded my macos.
  2. I also can run simple hello_world.go, seem the binary is too big to load into memory.

Simplified Makefile

run:
    go build -o app
    ./app

then, I run followings

$ make run
make: ./app: Cannot allocate memory
make: *** [run] Error 1

$ ./app
Killed: 9

$ ls -l app
-rwxr-xr-x   1 subchen  wheel  5902620 Apr 15 14:08 app

$ strip app

$ ls -l app
-rwxr-xr-x   1 subchen  wheel  5092444 Apr 15 14:13 app

$ ./app
Listening https://192.168.199.153:8080/v1/ ...
@rob-deutsch
Copy link

I believe this is a known issue (see #19734). There is also one comment in that thread noting that stripping the binary seems to fix it.

@ALTree
Copy link
Member

ALTree commented Apr 15, 2017

Yes, this is likely #19734. Please upgrade to go1.8.1, that should fix it.

Closing. Comment here if you can still reproduce with go1.8.1. and we'll re-open.

@ALTree ALTree closed this as completed Apr 15, 2017
@subchen
Copy link
Author

subchen commented Apr 15, 2017

I upgrade to go1.8.1, this issue is gone.
Thanks for your comments.

@taylortrimble
Copy link

taylortrimble commented Apr 21, 2017

I reproduced this on go 1.8.1

Steps

$ make clean
rm -f baltodash  api/balto.pb.go
rmdir api
go clean

$ go clean -i

$ make run
mkdir api
/Users/tylrtrmbl/thenewtricks/toolchains/protoc-3.2.0/bin/protoc -I ../balto-service/api --go_out=api ../balto-service/api/balto.proto
/Users/tylrtrmbl/thenewtricks/toolchains/go-1.8/bin/go build -o baltodash
./baltodash
make: ./baltodash: Cannot allocate memory
make: *** [run] Error 1

$ strip ./baltodash

$ make run
./baltodash
Welcome to Balto Dash!

go version:

go version go1.8.1 darwin/amd64

go env:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/tylrtrmbl/projects"
GORACE=""
GOROOT="/Users/tylrtrmbl/thenewtricks/toolchains/go-1.8.1"
GOTOOLDIR="/Users/tylrtrmbl/thenewtricks/toolchains/go-1.8.1/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/6n/fb27834j7wg9vvtc9nv5_2h80000gn/T/go-build422681697=/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"

Other Notes

I had this problem with a very similar project with go 1.8, and switching to go 1.8.1 did fix that project. However, the problem obviously still manifests for this project.

@ALTree
Copy link
Member

ALTree commented Apr 21, 2017

@tylrtrmbl are you absolutely sure that you nuked everything you had and rebuild it with go1.8.1? If yes, please open a new issue with details (a way to reproduce would be great, if you are allowed to share the code).

@taylortrimble
Copy link

Silly me. Spent an extra hour tracking it down this morning, and finally just moved my go 1.8 binary to the trash to prove it was using 1.8.1... it wasn't.

Now I found the problem.

Sorry for the noise.

@ALTree
Copy link
Member

ALTree commented Apr 21, 2017

No problem, thanks for checking.

@golang golang locked and limited conversation to collaborators Apr 21, 2018
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

5 participants