-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: bad debug_frame section on macOS with buildmode=pie [Debugging] #25841
Comments
CC @heschik @aclements |
dsymutil, I'm pretty sure, surprising nobody. main.main DIE in go.o, before external linker/dsymutil:
and the FDE:
It looks to me like dysmutil just doesn't adjust the addresses in .debug_frame, but I haven't looked at the code to figure out why. |
Is this important? I can step through dsymutil and try to figure out what the problem is but this feels like something we'd have to get fixed upstream. |
No |
@heschik : it seems like this issue is preventing debugging of go plugins on Mac OS X. My project is using go plugins and most of our engineers have Macs, so it's inconvenient to not be able to debug the code. As I have summarized in a comment in the related delve issue (go-delve/delve#1628), @aarzilli has stated that this particular issue is also a blocker for delve supporting go plugins on Mac. I know very little about how delve, DWARF, etc. work, so I'm not sure if this is the only issue still blocking that from working. However, based on @aarzilli 's statements, I would say the earlier claim that this issue is unimportant is no longer true. |
@jeremyfaller I think you would be first stop for this stuff now? Especially if you have a Mac handy -- I let mine rot. |
I'll take a look in the next couple of days. Whatever happens though, this won't make 1.14, so don't expect a mainline fix for quite some time. :) |
Apologies, for the latency. I finally got a chance to take a look at this. As @heschik suspected, it's dsymutil. [un]Surprisingly, dsymutil can't even verify its own output while generating the debug information. I've filed a bug with apple (7568255), and will follow up here with any responses. I have little experience debugging dsymutil myself, but I know a few people internally (@google) with some experience. I'll reach out to them next week, and see if they have any insights as well. I'll update this bug as we hear from Apple, or I gain insight from the local knowledgable people. |
@jeremyfaller did apple ever do anything about this? The problem has just become more pressing because on darwin/arm64 all externally linked executables are PIE (612b119) so on that architecture anything that uses cgo will encounter this problem, see: go-delve/delve#2346. |
This adds a workaround for the bug described at: golang/go#25841 Because dsymutil running on PIE does not adjust the address of debug_frame entries (but adjusts debug_info entries) we try to do the adjustment ourselves. Updates go-delve#2346
Well, I did follow up internally, and hit lots of roadblocks. No one had seen anything, and I just put it on hold mentally until I head from Apple. I never heard, and completely forgot about it. I'll admit it fell off my radar after that though. I'll ping the bug again with Apple, and see if I can pursue some extra channels we have. |
This adds a workaround for the bug described at: golang/go#25841 Because dsymutil running on PIE does not adjust the address of debug_frame entries (but adjusts debug_info entries) we try to do the adjustment ourselves. Updates go-delve#2346
This adds a workaround for the bug described at: golang/go#25841 Because dsymutil running on PIE does not adjust the address of debug_frame entries (but adjusts debug_info entries) we try to do the adjustment ourselves. Updates #2346
Any news on this one? Just hit it again and its highly frustrating and confusing when you can't trust your debugger anymore. |
Yes. The same issue in Golang for me. ( |
I can't debug the Go plugin on MAC, I'm going to crash, who has any solution? |
Nop @zonghaishang i saw some people made workarounds that compiled the plugin into the main binary. They made a script that, just for debugging, automatically rearanged the project to compile into a single binary and after compilation restore the initial state. Its a major hack and afaik does not work generically. Yet as i understand the issue is dysmutil and only apple can fix dysmutil. However i thought the workaround made things better, yet had no time to test it since we ditched plugins due to this issue for now all together. Just because i assume @jeremyfaller has also other things on his desk ill leave a ping for him here if he heared back 😃 |
I solved the plug-in debugging problem with container technology.
The screenshot correctly identifies the plug-in information and can also be executed inside the plug-in in a single step(step into :-) . |
👋🏻 @zonghaishang , could you please fix |
Change 064f34f cherrypicked from 5231ba2 made this problem start to happen on non-PIE builds on darwin/amd64. I guess what makes this problem happen is not PIE-ness but actually the lack of -pagezero_size being passed to the linker. I wonder what -pagezero_size does that makes dsymutil work. cc @cherrymui |
Go change 064f34f (which exists in Go 1.19.2 and following) removed the pagezero_size option from linker calls (because it is deprecated). This expanded the problem that exists on darwin/arm64 as well as PIE builds on darwin/amd64 to all darwin/amd64 builds. This problem is described on: golang/go#25841. This commit extends the darwin/arm64 workaround to darwin/amd64. Fixes go-delve#3194
Go change 064f34f (which exists in Go 1.19.2 and following) removed the pagezero_size option from linker calls (because it is deprecated). This expanded the problem that exists on darwin/arm64 as well as PIE builds on darwin/amd64 to all darwin/amd64 builds. This problem is described on: golang/go#25841. This commit extends the darwin/arm64 workaround to darwin/amd64. Fixes go-delve#3194
Go change 064f34f (which exists in Go 1.19.2 and following) removed the pagezero_size option from linker calls (because it is deprecated). This expanded the problem that exists on darwin/arm64 as well as PIE builds on darwin/amd64 to all darwin/amd64 builds. This problem is described on: golang/go#25841. This commit extends the darwin/arm64 workaround to darwin/amd64. Fixes go-delve#3194
Go change 064f34f (which exists in Go 1.19.2 and following) removed the pagezero_size option from linker calls (because it is deprecated). This expanded the problem that exists on darwin/arm64 as well as PIE builds on darwin/amd64 to all darwin/amd64 builds. This problem is described on: golang/go#25841. This commit extends the darwin/arm64 workaround to darwin/amd64. Fixes go-delve#3194
Crossreferencing https://reviews.llvm.org/D138763 |
Go change 064f34f (which exists in Go 1.19.2 and following) removed the pagezero_size option from linker calls (because it is deprecated). This expanded the problem that exists on darwin/arm64 as well as PIE builds on darwin/amd64 to all darwin/amd64 builds. This problem is described on: golang/go#25841. This commit extends the darwin/arm64 workaround to darwin/amd64. Fixes #3194
patchFrameInfoForObject accidentally truncates FDE addresses to the least significant 32bits, which causes the Go bug: golang/go#25841. Patch by Alessandro Arzilli Differential Revision: https://reviews.llvm.org/D138763
Closing, since the bug was in dsymutil and it has been fixed. |
Thanks for fixing this @aarzilli ! |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.10 darwin/amd64
(also reproduces with go1.11 built from tip)
What operating system and processor architecture are you using (
go env
)?What did you do?
Build any program with
go build -gcflags='-N -l' -buildmode pie
What did you expect to see?
debug_info has an entry for main.main that looks like this
but nothing in debug_frame covers anywhere close to the range 0x100090530...0x100090636, for example the first FDE is:
It seems to me that this is wrong but I could be missing something.
The text was updated successfully, but these errors were encountered: