Skip to content

symbolize: fix DWARF5 string-section handling and line-table metadata - #269

Open
anatasluo wants to merge 2 commits into
google:masterfrom
anatasluo:fix-dwarf5-line-table
Open

anatasluo wants to merge 2 commits into
google:masterfrom
anatasluo:fix-dwarf5-line-table

Conversation

@anatasluo

@anatasluo anatasluo commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes two DWARF5 reader issues introduced in dd1395a,
kept as separate commits:

  1. Correct string-section loading and propagation.
    Google3Addr2line::Prepare() omits .debug_str_offsets. Both
    line-reader call sites also use the .debug_line_str iterator when
    retrieving the .debug_str and .debug_str_offsets buffers,
    causing incorrect string lookups. If .debug_str is present but
    .debug_line_str is absent, this can dereference the section map's
    end iterator, which is undefined behavior.
    Load .debug_str_offsets and pass each section's own buffer and size.
  2. Accept line-table file metadata.
    The DWARF5 line reader accepts only path and directory-index fields,
    rejecting valid tables containing timestamps, sizes or MD5 checksums.
    Read integer timestamps and sizes, consume DW_FORM_data16 MD5 fields
    without interpreting the digest, and allow all five standard file
    fields. File and directory indexing is unchanged.

Validation

A small Clang 22.1.8-generated DWARF5 binary triggers a missing
string-offsets check before the first fix. With only the first commit,
parsing proceeds but the MD5-bearing line table yields no source lines.
With both commits, the queried function and source line match GNU
addr2line. GCC-generated DWARF4 and DWARF5 controls are unchanged.
The two new regressions fail before their respective fixes. They cover
strp/strx1 lookups through both handlers, decoded file metadata,
cursor alignment and truncated input.
All seven addr2line_test cases pass with Clang 22.1.8 and GCC 16.2.1.
Targeted ASan/UBSan checks also pass.

@snehasish

Copy link
Copy Markdown
Collaborator

Can you rebase to resolve the conflict so that I can approve the test workflows?

@anatasluo
anatasluo force-pushed the fix-dwarf5-line-table branch from a823ad8 to 9b75318 Compare September 30, 2026 16:09
@anatasluo

Copy link
Copy Markdown
Contributor Author

Can you rebase to resolve the conflict so that I can approve the test workflows?

@snehasish Rebased onto master and resolved the conflict. I had rebased #268 first because the two PRs conflict with each other. I'll rebase #269 again once #268 is merged. Thanks for your patience.

The DWARF5 support added in dd1395a passes .debug_line_str
in place of .debug_str and .debug_str_offsets at both line-reader
call sites. Indirect paths can resolve to the wrong strings, or
access a missing section. The ELF loader also omits .debug_str_offsets.

Pass each section from its own lookup and load .debug_str_offsets.
Add a regression using distinct section contents to check strp and
strx paths through both handlers.

Signed-off-by: Longjun Luo <luolongjuna@gmail.com>
The DWARF5 line reader added in dd1395a accepts only path and
directory-index fields. Valid timestamps, sizes and MD5 checksums
make it reject the table, so Clang MD5 entries produce no source lines.

Read integer timestamps and sizes, consume data16 checksums, and
allow all five standard file fields. Add a compact regression checking
decoded metadata, cursor alignment and truncated input.

Signed-off-by: Longjun Luo <luolongjuna@gmail.com>
@anatasluo
anatasluo force-pushed the fix-dwarf5-line-table branch from 9b75318 to 8273ba0 Compare September 30, 2026 17:51
@anatasluo

Copy link
Copy Markdown
Contributor Author

Hi, @snehasish . I've rebased this again after #268 merged, and there are no remaining conflicts. Could you approve the CI workflows and review when you have a chance? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants