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
- cmd/link: revise previous __DWARF segment protection fix Tweak the previous fix for issue 32673 (in CL 182958) to work around problems with c-shared build mode that crop up on some of the builders (1... — committed to golang/go by thanm 5 years ago
- fix build under go 1.13 and macos 10.15 https://github.com/golang/go/issues/32673 — committed to bnb-chain/node by ackratos 5 years ago
- MB-36672: Set GO_MAC_MINIMUM_VERSION to 1.13.3 To address this error seen with MacOS Catalina .. dyld: malformed mach-o image: segment __DWARF has vmsize < filesize Also see .. https://github.com/go... — committed to couchbase/tlm by abhinavdangeti 5 years ago
- macho: make __DWARF segment nonloadable Preallocate finite filesize for `__DWARF`, but make sure it is nonloadable by setting protection flags to always 0, and make it vmsize also 0. I found this is ... — committed to kubkon/zig by kubkon 4 years ago
Thanks! Can you make sure this gets backported to all maintenance branches, please? I can also open backport requests if you’d like.