Skip to content

Tweak our symbol resolution again#336

Open
godlygeek wants to merge 1 commit into
bloomberg:mainfrom
godlygeek:tweak_our_symbol_resolution_again
Open

Tweak our symbol resolution again#336
godlygeek wants to merge 1 commit into
bloomberg:mainfrom
godlygeek:tweak_our_symbol_resolution_again

Conversation

@godlygeek

Copy link
Copy Markdown
Contributor

I've found another case where the libpython gets mmap'ed by a process and breaks pystack's ability to find _PyRuntime. This time, I noticed it happening when Memray is symbolizing native stacks, which can trigger elfutils to mmap the text section of libpython if one of those native stack frames resolves to an address inside libpython.

When this happened, the symbol resolution callback was finding an address for the symbol, and discovering that that address was mapped, but not noticing that it fell within a different module entirely, since only a small part of libpython was mapped at that first mapping.

Address this by preferring matches which fall within the module we searched in over mappings which don't, while continuing to prefer a match in an earlier module over one in a later one.

I've found another case where the libpython gets mmap'ed by a process
and breaks pystack's ability to find `_PyRuntime`. This time, I noticed
it happening when Memray is symbolizing native stacks, which can trigger
elfutils to mmap the text section of libpython if one of those native
stack frames resolves to an address inside libpython.

When this happened, the symbol resolution callback was finding an
address for the symbol, and discovering that that address was mapped,
but not noticing that it fell within a different module entirely, since
only a small part of libpython was mapped at that first mapping.

Address this by preferring matches which fall within the module we
searched in over mappings which don't, while continuing to prefer
a match in an earlier module over one in a later one.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@godlygeek
godlygeek marked this pull request as ready for review July 22, 2026 20:42
@godlygeek

Copy link
Copy Markdown
Contributor Author

The 3.15 CI failures can be ignored. Those failures currently exist on main, and will be fixed by rebasing after #337 is merged.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.55%. Comparing base (1d399fa) to head (f2473ff).

Files with missing lines Patch % Lines
src/pystack/_pystack/unwinder.cpp 50.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #336      +/-   ##
==========================================
- Coverage   77.63%   77.55%   -0.09%     
==========================================
  Files          57       57              
  Lines        6601     6612      +11     
  Branches      628      630       +2     
==========================================
+ Hits         5125     5128       +3     
- Misses       1476     1484       +8     
Flag Coverage Δ
cpp 77.55% <50.00%> (-0.09%) ⬇️
python 77.55% <50.00%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants