symbolize: consume the full DW_FORM_addrx operand - #266
Open
anatasluo wants to merge 1 commit into
Open
Conversation
Advance the DIE cursor by the decoded operand width for fixed-width and ULEB128 addrx forms. Also initialize the operand length and avoid shadowing the decoded addrx2 index. Add DWARF 4 and DWARF 5 regression tests covering all supported addrx forms. Signed-off-by: Longjun Luo <luolongjuna@gmail.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
Hi @snehasish , could you approve the CI run and help find a reviewer for this fix? The CLA check is now passing, but the workflow is still waiting for maintainer approval. The patch fixes incorrect parsing of DWARF address-index operands and includes regression tests. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CompilationUnit::ProcessAttribute()advances the DIE cursor by exactly one byte for every supported address-index form. This is correct only forDW_FORM_addrx1and one-byte ULEB128 operands.DW_FORM_addrx2,DW_FORM_addrx3, andDW_FORM_addrx4leave the cursor 1, 2, and 3 bytes short, respectively. The ULEB128 forms,DW_FORM_addrxandDW_FORM_GNU_addr_index, leave it short whenever the encoded index requires more than one byte.The
DW_FORM_addrx2branch also declares a localaddr_indexthat shadows the outer variable, causing the decoded address to be read from entry 0 of.debug_addr.Reproduction
With GCC 16.1.1, a generated translation unit containing 200
noinline,usedfunctions and amainfunction that calls all of them was built with:The resulting
.dwocontains 201DW_TAG_subprogramDIEs whoseDW_AT_low_pcusesDW_FORM_addrx. Of those indices, 67 use a one-byte ULEB128 encoding and 134 use a multi-byte encoding; the maximum index is 397.Tracing the reader through the same
Google3Addr2line::Prepare()path used bycreate_gcovgives:high_pcafter one-byteaddrxhigh_pcafter multi-byteaddrxFindBadSubprograms()For example,
fn_0199uses address index 178.llvm-dwarfdumpandnm -Sreport itshigh_pc/ size as0xc. The old reader reports0xc01, while the patched reader reports0xc.As a one-byte control,
mainuses address index 68. Both readers report its correcthigh_pcof0xa49.The old reader therefore succeeds silently in this layout, but the corrupted
high_pcvalues produce oversized, overlapping function ranges.FindBadSubprograms()removes 133 affected subprograms, preventing samples from being attributed to their intended functions. The hand-built regression fixtures also demonstrate a harder failure mode in which the shifted cursor causes an out-of-range abbreviation lookup.Fix
Track and return the complete decoded operand width, initialize the width used by the fixed-size forms, and remove the shadowing declaration in the
DW_FORM_addrx2branch.The new DWARF 4 and DWARF 5 regression tests cover
addrx1,addrx2,addrx3,addrx4, one- and two-byteaddrx, andDW_FORM_GNU_addr_index. Both tests fail before this change and pass after it with GCC- and Clang-built test binaries.