go: debug/dwarf: cgo produces malformed DWARF data

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

$ go version
go version go1.12.6 darwin/amd64

Does this issue reproduce with the latest release?

Yes, including master.

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

macOS 10.15 beta 2

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mistydemeo/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mistydemeo/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.6/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.6/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/mistydemeo/oss/go/src/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/y2/qxl_xqt53vb2f5yrkmtdkyxc0000gn/T/go-build736553091=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Build a Go binary with cgo usage, for example https://github.com/sstephenson/launch_socket_server

What did you expect to see?

Binary is built and works.

What did you see instead?

Binary receives a SIGABRT with the following error:

dyld: malformed mach-o image: segment __DWARF has vmsize < filesize
fish: 'launch_socket_server' terminated by signal SIGABRT (Abort)

Examining some binaries produced by Go, it appears this bug predates macOS 10.15; however, the macOS 10.15 SDK is pickier about it, and any malformed binaries built against it will fail to execute with this error.

I’ve tested using the latest master to see if any of the commits reference #31459 affect it, but this behaviour still occurs.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 15 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks! Can you make sure this gets backported to all maintenance branches, please? I can also open backport requests if you’d like.