Skip to content

GH-126910: add test for manual frame unwinding - #144137

Merged
pablogsal merged 5 commits into
python:mainfrom
diegorusso:fp-unwind-test
Jan 27, 2026
Merged

GH-126910: add test for manual frame unwinding#144137
pablogsal merged 5 commits into
python:mainfrom
diegorusso:fp-unwind-test

Conversation

@diegorusso

@diegorussodiegorusso commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

Add a test that unwinds the stack using frame pointers. We test on any platform that frame pointers are enable (the others will be skipped). It tests with and without the JIT.

Output with PYTHON_JIT=0

#00 0xbcb53b0332f0 -> python
#01 0xbcb53b1c42b8 -> python
#02 0xbcb53b1ce4b8 -> python
#03 0xbcb53b1d758c -> python
#04 0xbcb53b0332f0 -> python
#05 0xbcb53b1c4774 -> python
#06 0xbcb53b1cfaec -> python
...
#68 0xbe2cbdec495c -> python
#69 0xeaad695b259c -> other
#70 0x60eaad695b267c -> other
#71 0x6be2cbdbc63f0 -> other
{"length": 53, "python_frames": 50, "jit_frames": 0, "other_frames": 3, "jit_code_ranges": 0, "jit_backend": "jit"}

Output with PYTHON_JIT=1

JIT ranges:
0xeaad6985c000-0xeaad6985e000
#00 0xbe2cbdc332f0 -> python
#01 0xbe2cbddc42b8 -> python
#02 0xbe2cbddce4b8 -> python
#03 0xbe2cbddd758c -> python
#04 0xbe2cbdc332f0 -> python
#05 0xbe2cbddc4774 -> python
#06 0xeaad6985c898 -> jit
...
#61 0xeaad6985b050 -> jit
#62 0xbe2cbddd42a4 -> python
#63 0xbe2cbddd72d4 -> python
#64 0xbe2cbde90d3c -> python
#65 0xbe2cbde910d0 -> python
#66 0xbe2cbde93490 -> python
#67 0xbe2cbdec3d30 -> python
#68 0xbe2cbdec495c -> python
#69 0xeaad695b259c -> other
#70 0x60eaad695b267c -> other
#71 0x6be2cbdbc63f0 -> other
{"length": 72, "python_frames": 49, "jit_frames": 20, "other_frames": 3, "jit_code_ranges": 1, "jit_backend": "jit"}

The core of the test has been taken from @pablogsal repository https://github.com/pablogsal/cpython-unwind

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @diegorusso for commit 5d53a15 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F144137%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jan 22, 2026
@diegorussodiegorusso added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jan 22, 2026
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @diegorusso for commit c179848 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F144137%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jan 22, 2026
Comment threadModules/_testinternalcapi.c Outdated
Comment threadLib/test/test_frame_pointer_unwind.py Outdated
Comment threadModules/_testinternalcapi.c
Comment threadModules/_testinternalcapi.c
}
#else
static const char *
classify_address(uintptr_t addr, int jit_enabled, PyInterpreterState *interp)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you get a warning here for interp being unused? I would have expected the compiler to complain for platforms without HAVE_DLADDR or WASI 🤔

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I tried compiling the branch above by removing code and I didn't see any warning even when passing -Wunused-parameter

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

but I spotted a double branch in the ifdef logic. Wasi can fallback in the final else :)

Comment threadModules/_testinternalcapi.c Outdated
Comment threadLib/test/test_frame_pointer_unwind.py

@pablogsalpablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! I just left a bunch of minor nits. Feel free to land without those

@pablogsal

Copy link
Copy Markdown
Member

Very cool and great work @diegorusso 💯

@diegorusso

Copy link
Copy Markdown
ContributorAuthor

LGTM! I just left a bunch of minor nits. Feel free to land without those

I've addressed all your reviews. Please have a look.

@pablogsal
pablogsal merged commit 66055d0 into python:mainJan 27, 2026
63 checks passed
@pablogsal

Copy link
Copy Markdown
Member

LGTM Great work!

@diegorusso
diegorusso deleted the fp-unwind-test branch January 27, 2026 13:47
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@diegorusso@bedevere-bot@pablogsal@Fidget-Spinner