-
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/compile: malformed DWARF ranges (child not contained in parent) #33188
Comments
We've recently ran into this issue as well when trying to generate GSYM files from Go binaries, see https://llvm.org/PR47157 for additional discussion. |
Do we still believe that this nesting is not actually mandated by the DWARF spec? |
Change https://golang.org/cl/248724 mentions this issue: |
Here is some more detail on what's happening in the compiler with this bug. There are two problems, one easy to fix and the other more difficult. The first problem is that the code that computes ranges for inlined routines is not doing the book-keeping properly to insure that child ranges are included in parent ranges when handling nested inlines. This problem triggers the verifier's "DIE address ranges are not contained in its parent's ranges" error. I sent CL 248724 to fix this. The second problem is trickier. The code that tracks variable scopes in the compiler is more or less independent from the code that handles inlining, meaning that when you have an inlined call whose callsite is positioned within a given lexical scope, the inlined routine DIE doesn't wind up as a child of the scope. This triggers a different error ("DIEs have overlapping address ranges"). Here is a reduced testcase that illustrates the second problem: File a.go:
begin b.go:
Here's an abstracted version of the DWARF for main.main you get in this situation:
where the ranges for the lexical block containing "b" look like
which overlaps with the inlined routine but doesn't entirely contain it (and in addition the two DIEs in question are siblings within the main.main DIE, as opposed to having the scope parent the inline. Fixing this is a good deal more complicated, since the two phases (scope generation and inline handling) operate more or less independently at the moment. |
Repair the code that generates PC ranges for DWARF inlined routine instances to insure that if II Y is a child of II X within the inline tree, X's ranges include the ranges from Y. This is similar to what we're already doing for DWARF scopes. Updates #33188. Change-Id: I9bb552777fcd1ae93dc01872707667ad092b1dd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/248724 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com> Trust: Than McIntosh <thanm@google.com>
@thanm, can you update this bug with what still needs to be done? Should this still be for 1.16 or should we retarget the rest of the work to 1.17? |
The part that's missing is integrating scope generation with inline generation, as mentioned before. This means (probably) unifying the mechanism used to represent scopes/inlines (scopes are stored using what amounts to a side table, whereas inlines are embedded into the Pos table). I think it would be better to retarget this work for 1.17, since it seems as though it will require a fair number of changes. I think we would be better off landing it after the dev.regabi branch is merged, in particular. |
Is this likely to happen for Go 1.17, or should we shift the milestone? |
Unlikely to happen for 1.17 -- I will shift. Thanks. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Build this program:
in the usual way, e.g. "go build main.go". Then run
to check the resulting dwarf.
What did you expect to see?
Clean run
What did you see instead?
A number of errors of the form: "error: DIE address ranges are not contained in its parent's ranges:"
Here is one instance:
which is contained in this DIE:
so definitely an inconsistency. Note that the top-level parent is:
There is nothing in the DWARF spec as far as I know that mandates this sort of address range nesting consistency, but I think it would probably be nice if a given inlined subroutines ranges were completely nested inside the parent DIE.
The text was updated successfully, but these errors were encountered: