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

Go test fails with signal: bus error on MacOS Catalina #35478

Closed
suizman opened this issue Nov 9, 2019 · 6 comments
Closed

Go test fails with signal: bus error on MacOS Catalina #35478

suizman opened this issue Nov 9, 2019 · 6 comments

Comments

@suizman
Copy link

suizman commented Nov 9, 2019

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

$ go version
go version go1.13.4 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/Users/suizman/go/bin"
GOCACHE="/Users/suizman/Library/Caches/go-build"
GOENV="/Users/suizman/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/suizman/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/suizman/go/src/github.com/bbva/qed/go.mod"
CGO_CFLAGS="-I/Users/suizman/go/src/github.com/bbva/qed/c-deps/rocksdb/include"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-L/Users/suizman/go/src/github.com/bbva/qed/c-deps/libs -lrocksdb -lsnappy -ljemalloc -lstdc++ -ldl -lpthread -lm -Wl,-undefined -Wl,dynamic_lookup"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gz/br0p105n7nx6tsx8gxkwnnbw0000gn/T/go-build446523722=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Executing a single test in my project:
go test -timeout 30s github.com/bbva/qed/consensus -run \^\(TestApplyAdd\)\$

This seams to happen only in projects when you use CGO.

What did you expect to see?

Pass the tests.

What did you see instead?

signal: bus error
FAIL	github.com/bbva/qed/consensus	0.010s
FAIL

Full system log > https://gist.github.com/suizman/3907c15e818807604ffe4a11095c7020#file-consensus-test

@suizman suizman changed the title Go test fails with signal: bus error Go test fails with signal: bus error on MacOS Catalina Nov 9, 2019
@bcmills
Copy link
Contributor

bcmills commented Nov 10, 2019

A bus error in a Cgo program generally indicates memory corruption, such as a use-after-free bug (perhaps due to a missing or misplaced runtime.KeepAlive), missing validation (such as a length check), or erroneous pointer manipulation.

I recommend opening an issue against github.com/bbva/qed. (A bug in the Go runtime or toolchain is not impossible, but given the evidence so far seems much less likely than a bug in the test or the API it is testing.)

@bcmills bcmills closed this as completed Nov 10, 2019
@suizman
Copy link
Author

suizman commented Nov 10, 2019

@bcmills thanks for your response. I'm curious why this error only occurs on darwin and not in Linux. The Cgo code is the same for both OS.

@bcmills
Copy link
Contributor

bcmills commented Nov 10, 2019

The macOS and Linux C toolchains are markedly different. macOS tends to default to clang; Linux tends to default to gcc, although some systems may use clang instead. Moreover, the syscall APIs, threading libraries, and other aspects of the C runtime vary greatly between the two.

Most likely the program is triggering some sort of undefined behavior that happens to crash hard on macOS and not on Linux. You might be able to figure out more by running under various sanitizers (-fsanitize=[…]) on the macOS machine.

@bcmills
Copy link
Contributor

bcmills commented Nov 10, 2019

(I should add, though — sanitizers will catch errors that occur only on the C side. They will not, in general, diagnose errors that arise from interactions across language boundaries.)

@suizman
Copy link
Author

suizman commented Nov 10, 2019

Thanks, I'll keep debugging and try the sanitizer.

@suizman
Copy link
Author

suizman commented Nov 12, 2019

I've compiled the project C dependencies with most recent clang version from brew and not the one which comes with the official xcode command line tools and it worked.
I'll contact Apple support for further information.

@golang golang locked and limited conversation to collaborators Nov 11, 2020
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

3 participants