go: Go 1.12.1 dsymutil segmentation fault on MacOS Sierra
What version of Go are you using (go version
)?
$ go version go version go1.12.1 darwin/amd64 $ sw_vers ProductName: Mac OS X ProductVersion: 10.12.6 BuildVersion: 16G1114 $ clang --version Apple LLVM version 9.0.0 (clang-900.0.39.2) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
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 GOARCH="amd64" GOBIN="" GOCACHE="/Users/user906782/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/user906782/go" GOPROXY="" GORACE="" GOROOT="/Users/user906782/homebrew/Cellar/go/1.12.1/libexec" GOTMPDIR="" GOTOOLDIR="/Users/user906782/homebrew/Cellar/go/1.12.1/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" 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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/b1/txl5_d893yj3rw0bg_kyplt80000ln/T/go-build229507920=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Run make VERSION=0.36.0 build-minimal
with release 0.36.0 of replicatedhq/ship on MacOS Sierra. (Running on High Sierra or Mojave seems to be fine)
What did you expect to see?
Compilation finishes.
What did you see instead?
/usr/local/Cellar/go/1.12/libexec/pkg/tool/darwin_amd64/link: running dsymutil failed: signal: segmentation fault
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (11 by maintainers)
Commits related to this issue
- cmd/link: add optional sanity checking for duplicate symbols Introduce a new linker command line option "-strictdups", which enables sanity checking of "ok to duplicate" symbols, especially DWARF inf... — committed to golang/go by thanm 5 years ago
- test: new test for issue 30908 New test case designed to mimic the code in issue 30908, which features duplicate but non-indentical DWARF abstract subprogram DIEs. Updates #30908. Change-Id: Iacb4b... — committed to golang/go by thanm 5 years ago
- [release-branch.go1.12] cmd/compile: better handling for PAUTOHEAP in DWARF inline gen When generating DWARF inline info records, the post-SSA code looks through the original "pre-inline" dcl list fo... — committed to golang/go by thanm 5 years ago
- test: fix fixedbugs/issue30908.go to work with no-opt builder Update the issue 30908 test to work with the no-opt builder (this requires a corresponding change in the linker as well). As part of this... — committed to golang/go by thanm 5 years ago
For posterity, here’s what’s happening with this bug.
The function causing the issue is here:
This is small enough to be an inlining candidate; it gets inlined in its home package and in other packages that import that package.
During the home package compile, ‘vals’ is promoted to the heap, and in the process the dcl node for the param updated, converting its class from PPARAMOUT to PAUTOHEAP. This happens at esc.go:2175.
This change in class confuses the DWARF generation code, specifically createDwarfVars. The code there winds up treating PAUTOHEAP the same as PAUTO, hence ‘vals’ is reclassified as a local and not an output parameter. This has a cascading effect and means that the abstract subprogram DIE generated for chartutil.ReadValues is slightly different in its home package relative to what gets emitted in other packages that inline it.
The fix is fairly straightforward in createDwarfVars(); I also wrote a separate patch to add some checking to the linker to try to detect these cases early and on Linux (at the moment it seems that we only see problems on Macos and with specific more strict versions of dsymutil).
@benesch thanks for the heads-up. Backport seems reasonable. I will discuss with the other compiler/runtime folks.
Wed Mar 20 13:28:20 EDT 2019
I ran dsymutil in the debugger and it does indeed look as though it is encountering bad DWARF.
Offending compiliation unit is here:
It appears that the routine ‘chartutil.ReadValues’ is being inlined into ‘chartutil.CoalesceValues’. The inlined routine subprogram DIE being generated looks like
The second formal parameter abstract_origin offset (0xd5892a) is bad – it looks as though it’s coming out somewhere in between the formal parameter DIEs in the subprogram it’s referring to. So almost certainly some sort of compiler problem here.
I’ll grab the bug if that is ok and see about trying to come up with a compiler test case.
I can reproduce. Additional commands I needed (in case anyone else needs to reproduce):
There’s at least a bug in dsymutil. It probably shouldn’t segfault, no matter the input we give it. Presumably we’re generating some dwarf data that dsymutil can’t handle. I don’t know what that might be. I’m having trouble convincing the go tool to leave behind enough work directories to reproduce directly with dsymutil. Still working on that, will probably have to wait until tomorrow.