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/link: signal SIGBUS: bus error during linking with sufficient disk space #41473

Closed
sauravhaloi opened this issue Sep 18, 2020 · 9 comments
Closed

Comments

@sauravhaloi
Copy link

@sauravhaloi sauravhaloi commented Sep 18, 2020

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

$ go version
go version go1.15.2 linux/amd64

Does this issue reproduce with the latest release?

Yes. I am observing this issue on latest go release in Ubuntu 20.04.1 LTS (Linux, amd64)

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/shaloi/.cache/go-build"
GOENV="/home/shaloi/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/shaloi/workspace/golang/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/shaloi/workspace/golang"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/golang/latest"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/golang/latest/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build714599985=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ go run main.go

What did you expect to see?

my application to be successfully built and executed.

What did you see instead?

$ go run main.go 
# command-line-arguments
unexpected fault address 0x7f06bc66f24f
fatal error: fault
[signal SIGBUS: bus error code=0x2 addr=0x7f06bc66f24f pc=0x517262]

goroutine 1 [running]:
runtime.throw(0x6cf03c, 0x5)
	/usr/local/go/src/runtime/panic.go:1116 +0x72 fp=0xc000106ce0 sp=0xc000106cb0 pc=0x436392
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:717 +0x485 fp=0xc000106d10 sp=0xc000106ce0 pc=0x44cae5
cmd/internal/goobj2.(*Reloc).Sym(...)
	/usr/local/go/src/cmd/internal/goobj2/objfile.go:317
cmd/link/internal/loader.Reloc2.Sym(0x7f06bc66f241, 0xc000da2900, 0xc000073c00, 0x0, 0x4)
	/usr/local/go/src/cmd/link/internal/loader/loader.go:83 +0x22 fp=0xc000106d40 sp=0xc000106d10 pc=0x517262
cmd/link/internal/loader.(*Loader).UndefinedRelocTargets(0xc000073c00, 0x1, 0x6cf60b, 0x6, 0x8b2b20)
	/usr/local/go/src/cmd/link/internal/loader/loader.go:2918 +0xf6 fp=0xc000106e08 sp=0xc000106d40 pc=0x524a96
cmd/link/internal/ld.(*Link).loadlib(0xc000073880)
	/usr/local/go/src/cmd/link/internal/ld/lib.go:594 +0x5a5 fp=0xc000106eb8 sp=0xc000106e08 pc=0x5c2445
cmd/link/internal/ld.Main(0x870840, 0x20, 0x20, 0x1, 0x7, 0x10, 0x0, 0x0, 0x6da8ff, 0x1b, ...)
	/usr/local/go/src/cmd/link/internal/ld/main.go:232 +0xd05 fp=0xc000107118 sp=0xc000106eb8 pc=0x5e1e05
main.main()
	/usr/local/go/src/cmd/link/main.go:68 +0x1dc fp=0xc000107f88 sp=0xc000107118 pc=0x65dd1c
runtime.main()
	/usr/local/go/src/runtime/proc.go:204 +0x209 fp=0xc000107fe0 sp=0xc000107f88 pc=0x438b89
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1374 +0x1 fp=0xc000107fe8 sp=0xc000107fe0 pc=0x46af01

Additional observations

  • this error is only observed with go 1.15.2
  • as mentioned in Issue: #41466, in my case, there was no disk space issue
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            5.8G     0  5.8G   0% /dev
tmpfs           1.2G  2.2M  1.2G   1% /run
/dev/sda8       202G   59G  133G  31% /
tmpfs           5.9G  383M  5.5G   7% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           5.9G     0  5.9G   0% /sys/fs/cgroup
/dev/sda1       496M   60M  437M  12% /boot/efi
tmpfs           1.2G   20K  1.2G   1% /run/user/125
tmpfs           1.2G   80K  1.2G   1% /run/user/1000

@sauravhaloi
Copy link
Author

@sauravhaloi sauravhaloi commented Sep 18, 2020

I am not encountering this issue with go 1.15 or go 1.15.1

Loading

@davecheney
Copy link
Contributor

@davecheney davecheney commented Sep 18, 2020

Are you able to provide the source of the program you were compiling.

Loading

@sauravhaloi
Copy link
Author

@sauravhaloi sauravhaloi commented Sep 18, 2020

Are you able to provide the source of the program you were compiling.

Hi.. I wont be able to provide the source of the program.

Loading

@ianlancetaylor ianlancetaylor changed the title signal SIGBUS: bus error during linking cmd/link: signal SIGBUS: bus error during linking with sufficient disk space Sep 18, 2020
@ianlancetaylor ianlancetaylor added this to the Go1.16 milestone Sep 18, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Sep 18, 2020

Loading

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Sep 18, 2020

I don't think the linker is changed between Go 1.15.1 and 1.15.2. Weird...

Loading

@thanm
Copy link
Contributor

@thanm thanm commented Sep 18, 2020

Especially surprising given the failure mode. Looking at

cmd/link/internal/loader.Reloc2.Sym(0x7f06bc66f241, 0xc000da2900, 0xc000073c00, 0x0, 0x4)
	/usr/local/go/src/cmd/link/internal/loader/loader.go:83 +0x22 fp=0xc000106d40 sp=0xc000106d10 pc=0x517262

that implies that Relocs.At2() returned a Reloc2 value with '*goobj2.Reloc' field set to a garbage value, which looking at the code seems impossible. Very strange.

Loading

@jeremyfaller
Copy link
Contributor

@jeremyfaller jeremyfaller commented Sep 18, 2020

@cherrymui suggested in chat that it might be corrupted object files. With full credit to her idea, if you do a clean build, does the problem persist?

Loading

@sauravhaloi
Copy link
Author

@sauravhaloi sauravhaloi commented Sep 21, 2020

@jeremyfaller As suggested, I did a build of my application after doing a clean up with go clean -i -r -x -cache, and the issue is resolved. I usually upgrade my Go versions without doing a cleanup of the object files, cache etc. Do you think that must have caused this? Thank you so much for your help!

Loading

@jeremyfaller
Copy link
Contributor

@jeremyfaller jeremyfaller commented Sep 21, 2020

between 1.15.1, and 1.15.2, the object files shouldn't have changed, but I'd imagine the tooling would have triggered the rebuilds that were required. That it didn't might mean you got a lucky hash collision (unlikely), there's a bug (possible) or there's something weird about your setup. Without serious investigation (likely requiring the code), I doubt we'll ever know.

I'm glad it's working now.

Loading

@golang golang locked and limited conversation to collaborators Sep 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants