cmd/compile: malformed DWARF ranges (child not contained in parent) #33188
What version of Go are you using (
The text was updated successfully, but these errors were encountered:
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:
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 <email@example.com> TryBot-Result: Go Bot <firstname.lastname@example.org> Reviewed-by: Cherry Zhang <email@example.com> Reviewed-by: David Chase <firstname.lastname@example.org> Trust: Than McIntosh <email@example.com>
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.