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
cmd/link: empty __debug_ranges section on darwin #21945
Comments
Managed to reproduce this locally, it looks like go.o has a reasonable looking debug_ranges section but it doesn't survive the external linker (it could be that there is a subtle problem with debug_ranges). I couldn't find any way to convince the system linker to emit diagnostic output. |
go env as requested
|
CC @heschik |
Huh, and here I was thinking that dsymutil crashing was a bad failure mode. At least that gives you a hint; I don't really know how to debug it when it's just mangling the result. I don't have a Mac handy so I can offer suggestions but not much more at the moment. We know that this works at least some of the time, so there must be something about this code. dsymutil seems quite sensitive to malformed DWARF, so perhaps there's a particular function in here somewhere that's triggering a compiler bug? I'd start by building a program with the package and seeing if that worked. If so, hopefully there's a particular test that's triggering the problem and it can just be bisected from there. |
I'm happy to recreate this in a VM and provide SSH access if that's of any help. |
where is dsymutil called in this case? I don't see it in the output of |
Yeah, I don't think it's logged. go/src/cmd/link/internal/ld/lib.go Lines 1337 to 1358 in e9cbabb
I imagine you can confirm with truss or something. I guess I should say that I don't have any particular evidence that dsymutil is the one messing things up, but that's where all of my OSX-specific DWARF issues have been, so I'm just assuming it's the problem. It shouldn't change a divide-and-conquer debugging approach much though. @deasmi, I can get access to a Mac around here if @aarzilli needs a second pair of eyes. I appreciate the offer though. |
Dug more into this, if you call dsymutil with -verbose some useful output is emitted. The offending function seems to be patchRangesForUnit note in particular the warning output in emitRangesEntries which is never reached because of the logic inside patchRangesForUnit. It seems like they have decided to not support base selection entries, in fact this problem can be reproduced with trivial programs as long as |
PS. I don't have a solution for this, without a base selection entry the other entries are relative to the low pc of the compile unit, can the compiler emit a relocation like that? Also I was debugging dsymutil and, besides the base selection problem, I'm not convinced that there aren't other bugs, the very first |
Ugh, that's a shame.
Huh. Location lists have the exact same wording and I didn't notice. But at one point, before I switched to DWARF 4, I wasn't using base selection entries, and GDB was still able to understand my location lists. So either I don't understand what CU-relative addressing means, or this is a common enough mistake that GDB can deal with it anyway. It might be worth just putting absolute addresses in there and see what happens. This is kind of like an R_DWARFREF, but since there's only one .text and there could be multiple CUs, it can't be that easy. If there's a way to do this I don't know what it is. |
There was something nagging me about the verbose output of dsymutil so I took another look:
in hindsight I should have been more worried, sure enough this DIE is mangled in the output:
despite the fact that the DW_AT_type does get copied in the output. This happens 86 times in the libvirt test build. I think I've finally found the cause of this old bug of mine that I had to unjustly close because I couldn't reproduce it on 1.8. |
Change https://golang.org/cl/66850 mentions this issue: |
https://golang.org/cl/69973 gives us a CU per package, so the compiler is in a slightly better position to do CU-relative addressing -- the addresses can be expressed as a relocation vs. the first function in the package. But that'll get messed up when the linker eliminates a dead function, so I still don't have a good solution. Maybe leave the elimination of text symbols to the external linker? Pretty iffy. Someone should probably file an LLVM bug to get them to support base selection entries so there's some light at the end of the tunnel, at least. |
Change https://golang.org/cl/72371 mentions this issue: |
This issue was initially discussed here: https://github.com/derekparker/delve/issues/964
When compiling the tests of https://github.com/deasmi/terraform-provider-libvirt/tree/graphicsandvnc with optimizations disabled the resulting binary has a 4kb __debug_ranges section that consists almost entirely of zeroes, with the exception of a few bytes at the end of the section.
Output of
go test -x
here: https://www.dropbox.com/s/kmn2g8ibsd5q9po/gotest.txt?dl=0What version of Go are you using (
go version
)?go version go1.9 darwin/amd64
The text was updated successfully, but these errors were encountered: