profile
viewpoint

Ask questionscmd/link: segmentation fault during mach-o linking

Seen in the darwin-amd64-nocgo builder (https://build.golang.org/log/c13c6d21b5bfb8d2220b0244e381440eb959415b), an unexpected fault address in strings.IndexByte during linking.

(I'm not sure whether the linker is playing any interesting games with mapped memory at this point, so if you can rule out a linker bug please file an issue against an appropriate other package.)

# crypto/rc4.test
unexpected fault address 0x1800000020
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x1800000020 pc=0x1002a7c]

goroutine 1 [running]:
runtime.throw(0x128e871, 0x5)
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/runtime/panic.go:774 +0x72 fp=0xc000749098 sp=0xc000749068 pc=0x102d312
runtime.sigpanic()
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/runtime/signal_unix.go:401 +0x3de fp=0xc0007490c8 sp=0xc000749098 pc=0x104236e
indexbytebody(0x1800000020, 0xc00133c210, 0x62e, 0x198e, 0xc000485940, 0xc000749140, 0x11a357c, 0x1246ca0, 0xc000478000, 0x1290a2b, ...)
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/internal/bytealg/indexbyte_amd64.s:48 +0x2c fp=0xc0007490d0 sp=0xc0007490c8 pc=0x1002a7c
strings.IndexByte(...)
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/strings/strings.go:151
strings.Index(0x1800000020, 0xc00133c210, 0x128e22a, 0x1, 0x8)
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/strings/strings.go:1033 +0x5f7 fp=0xc000749150 sp=0xc0007490d0 pc=0x10c3ae7
strings.Contains(...)
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/strings/strings.go:99
cmd/link/internal/ld.machosymtab(0xc00006a000)
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/cmd/link/internal/ld/macho.go:880 +0x25a fp=0xc0007491e8 sp=0xc000749150 pc=0x11a382a
cmd/link/internal/ld.Domacholink(0xc00006a000, 0x525bfff)
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/cmd/link/internal/ld/macho.go:952 +0x2f fp=0xc000749260 sp=0xc0007491e8 pc=0x11a46bf
cmd/link/internal/amd64.asmb2(0xc00006a000)
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/cmd/link/internal/amd64/asm.go:712 +0x7d4 fp=0xc0007492d0 sp=0xc000749260 pc=0x11d1d24
cmd/link/internal/ld.Main(0x1452fa0, 0x10, 0x20, 0x1, 0x7, 0x10, 0x129829b, 0x1b, 0x1294ecd, 0x14, ...)
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/cmd/link/internal/ld/main.go:271 +0xd9a fp=0xc000749428 sp=0xc0007492d0 pc=0x11aaa6a
main.main()
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/cmd/link/main.go:65 +0x1d6 fp=0xc000749f60 sp=0xc000749428 pc=0x1213a96
runtime.main()
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/runtime/proc.go:203 +0x21e fp=0xc000749fe0 sp=0xc000749f60 pc=0x102ec9e
runtime.goexit()
	/private/var/folders/9w/4l2_g3kx01x199n37fbmv3s80000gn/T/workdir-host-darwin-10_14/go/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc000749fe8 sp=0xc000749fe0 pc=0x1059b31
FAIL	crypto/rc4 [build failed]

@cherrymui @mdempsky @ianlancetaylor @jeremyfaller

golang/go

Answer questions cherrymui

We do use mmap on darwin but this doesn't seem like caused by mapped memory to me, because

  • we never unmap memory
  • the string length, 0xc00133c210, seems wrong. But the string length does not come from mapped memory, at least not directly.

But I can't be sure.

useful!

Related questions

cmd/go: cannot find module providing package error stops `go get` processing hot 3
vendor/golang.org/x/xerrors/adaptor_go1_13.go:16:14: undefined: errors.Frame ... hot 2
cmd/vet: potential false positive in the "suspect or" check hot 2
cmd/go: needs a better error than "missing dot in first path element" when GOROOT is set incorrectly hot 2
x/xerrors: fails to compile on tip hot 1
cmd/go: `go clean <package>` downloads modules hot 1
cmd/cgo error: runtime: unknown pc 0x7fff5c805b86 hot 1
runtime: crash with "invalid pc-encoded table" hot 1
cmd/link: showing many ld warnings of "building for macOS, but linking in object file" hot 1
runtime: go program crach, it seems fall into infinite loop hot 1
cmd/go: major version without preceding tag must be v0, not v1 - breaks build of github.com/go-check hot 1
gollvm: Using External Go Packages with gollvm hot 1
runtime: macOS Sierra builders spinning hot 1
cmd/go: Problem using go modules hot 1
cmd/go: "unrecognized import path" for local packages after updating to go1.13 hot 1
Github User Rank List