Skip to content

fix(dyninst): Fix use-after-unmap from filename-keyed DwarfHandle cache - #29

Open
kcossett-amd wants to merge 1 commit into
dyninst_13from
users/kcossett-amd/elf-x-fix
Open

fix(dyninst): Fix use-after-unmap from filename-keyed DwarfHandle cache#29
kcossett-amd wants to merge 1 commit into
dyninst_13from
users/kcossett-amd/elf-x-fix

Conversation

@kcossett-amd

@kcossett-amd kcossett-amd commented Aug 14, 2026

Copy link
Copy Markdown

Motivation

For background on the issue being fixed, see ROCm/rocm-systems#10171

The problem is that the DwarfHandle cache is keyed only on filename, so it hands back a handle bound to an Elf_X whose image ~Symtab already unmapped; this verifies the binding and rebuilds the entry when it differs.

Technical Details

Reuse a cached DwarfHandle only when its origFile() matches the Elf_X being passed in, otherwise drop the stale entry and build a new handle.

Test Plan

ROCm/rocm-systems#10255 (comment)

Test Result

See Test PR on rocprofiler-systems, all tests pass.

Submission Checklist

@kcossett-amd

Copy link
Copy Markdown
Author

ROCm/rocm-systems#10255 (comment)
Confirmed that this fixes the issue.

@kcossett-amd
kcossett-amd requested a lite review from Copilot August 18, 2026 15:09
@kcossett-amd kcossett-amd changed the title fix(rocprofiler-systems): Fix use-after-unmap from filename-keyed DwarfHandle cache fix(dyninst): Fix use-after-unmap from filename-keyed DwarfHandle cache Aug 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a use-after-unmap hazard in Dyninst’s DWARF handling by preventing DwarfHandle reuse when a filename-cache hit refers to a handle built from a different Elf_X instance than the one currently being parsed.

Changes:

  • Validate cached DwarfHandle entries by comparing origFile() against the incoming Elf_X*.
  • Evict filename-cache entries that don’t match the current Elf_X to force rebuilding a fresh handle.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@kcossett-amd
kcossett-amd marked this pull request as ready for review August 18, 2026 15:13
@kcossett-amd
kcossett-amd requested a review from a team as a code owner August 18, 2026 15:13

@sputhala-amd sputhala-amd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this fix is merged, is the plan to revert ROCm/rocm-systems#10171?

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.

3 participants