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

cmd/cgo: program got a SIGBUS signal #31593

Closed
duanbing opened this issue Apr 21, 2019 · 6 comments

Comments

@duanbing
Copy link

commented Apr 21, 2019

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

$ go version
go version go1.12.4 darwin/amd64

Does this issue reproduce with the latest release?

yes, go version go1.12.4 darwin/amd64 is the latest version I can download.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/duanbing/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/duanbing/Project/Go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.4/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/xxxxx/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/35/1f0_9bnn0dvc0mdr0kv8dy08cm5r19/T/go-build681850907=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I write a cgo program, and use go test to run the unit test.
but if I set GOGC=off, go test run as I expect.

What did you expect to see?

tests finished without crash when GOGC=on.

What did you see instead?

I got SIGBUS signal if I just run go test.

@ALTree

This comment has been minimized.

Copy link
Member

commented Apr 21, 2019

Thanks for the report.

It's possible that this is caused by issues with the cgo part of your program. It's possible that the bug is in the C code of your program, and not in the Go runtime.

Can you provide a (possibly small) reproducer? Otherwise it won't be possible to investigate this.

@ALTree ALTree changed the title Cgo program got a SIGBUS signal cmd/cgo: program got a SIGBUS signal Apr 21, 2019

@duanbing

This comment has been minimized.

Copy link
Author

commented Apr 22, 2019

Thanks, @ALTree . the codes are too large, so I didn't post it here. I will mimic a simple one to reproduce it. BTW, can you give me some tips about what kinda scenario I will get this error?

@duanbing

This comment has been minimized.

Copy link
Author

commented Apr 22, 2019

this is the associated issue, WAVM/WAVM#151 , its maybe helpful.

@duanbing

This comment has been minimized.

Copy link
Author

commented Apr 22, 2019

@golang golang deleted a comment from 40345839668 Apr 22, 2019

@ALTree

This comment has been minimized.

Copy link
Member

commented Apr 22, 2019

@duanbing Thanks for the investigation.

Unfortunately, as I wrote above, this kind of crashes are often caused by issues in the C code, so I'm afraid this issue won't be actionable from the Go project's side unless you're able to to reduce your large code into a smaller reproducer.

I'll leave this open with a WaitingForInfo label, so feel free to post updates here.

@duanbing

This comment has been minimized.

Copy link
Author

commented Apr 24, 2019

I fixed it by allocating the memory in mmapped section, not in current stack.

Thanks all!

@duanbing duanbing closed this Apr 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.