-
Notifications
You must be signed in to change notification settings - Fork 18k
debug/dwarf: cgo produces malformed DWARF data #32673
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
Comments
Thank you for this report @mistydemeo! I shall page some experts @ianlancetaylor @heschik @dr2chase |
I can take an initial look at this. NB, possibly related to #21647 ? |
That definitely looks related. |
Well, I am a little out of my depth here (not a MachO expert) but looking at the dyld source here around line 287 it might be possible to work around this by setting the initial protection to zero. I don't have any viable way to test the fix, though -- the strict checking in question is hardwired based on the OS version it looks like. @mistydemeo if I send a CL would you be able to test it (e.g. apply patch to Go source, rebuild, etc)? |
@thanm Yes, absolutely. I can test. I've been testing a few tweaks locally so far, glad to test anything you send me too! |
Change https://golang.org/cl/182958 mentions this issue: |
OK, thanks. I sent a CL -- if you can patch that in and see if it helps, I'd be grateful. |
Confirmed that has fixed the issue. After building Go at this branch, I tried rebuilding |
Cool, glad to hear it. I'll see about getting it reviewed and checked in. Thanks for your help. |
Thanks! Can you make sure this gets backported to all maintenance branches, please? I can also open backport requests if you'd like. |
Yes, if you can open requests I can follow up. |
@gopherbot please consider this for backport, it's a regression |
Backport issue(s) opened: #32696 (for 1.11), #32697 (for 1.12). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/183237 mentions this issue: |
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 (10.11, 10.12). We now consistently set vmaddr and vmsize to zero for the DWARF segment regardless of build mode. Updates #32673 Change-Id: Id1fc213590ad00c28352925e2d754d760e022b5e Reviewed-on: https://go-review.googlesource.com/c/go/+/183237 Reviewed-by: Cherry Zhang <[email protected]> Reviewed-by: David Chase <[email protected]>
To address this error seen with MacOS Catalina .. dyld: malformed mach-o image: segment __DWARF has vmsize < filesize Also see .. golang/go#32673 Change-Id: I5aa6f86ba7c45bc380d748f35601ac8fb40e688e Reviewed-on: http://review.couchbase.org/117022 Reviewed-by: Chris Hillery <[email protected]> Tested-by: Build Bot <[email protected]>
I still encountered this issue in the Go newest version v1.14.2. I posted an issue here, could someone please check? #38765 |
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 required to make the `dyld` happy over at Go issue board: golang/go#32673 Also, preallocate dwarf debug sections that go within the `__DWARF` segment.
What version of Go are you using (
go version
)?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
OutputWhat 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: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.
The text was updated successfully, but these errors were encountered: