Skip to content

gh-156545: Fix flamegraph export RecursionError on deeply recursive programs - #156546

Merged
pablogsal merged 4 commits into
python:mainfrom
tonghuaroot:gh-156545-flamegraph-deep-stack
Oct 5, 2026
Merged

pablogsal merged 4 commits into
python:mainfrom
tonghuaroot:gh-156545-flamegraph-deep-stack

Conversation

@tonghuaroot

@tonghuaroot tonghuaroot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Flamegraph export raises RecursionError when sampled stacks exceed the usual Python recursion limit. Temporarily allow enough recursion for the unwinder's 1,536-frame maximum during export, restoring the original limit in finally.

Tests cover a full 1,536-frame export and limit restoration after success, empty output, and an export error. The profiling test suite passes.

Closes #156545.

@pablogsal pablogsal added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Oct 5, 2026
@pablogsal
pablogsal enabled auto-merge (squash) October 5, 2026 14:06
@bedevere-app

bedevere-app Bot commented Oct 5, 2026

Copy link
Copy Markdown

GH-158851 is a backport of this pull request to the 3.15 branch.

@pablogsal
pablogsal merged commit 1441e51 into python:main Oct 5, 2026
58 checks passed
pablogsal added a commit that referenced this pull request Oct 5, 2026
…rsive programs (GH-156546) (#158851)

Backport of GH-156546.

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
pablogsal added a commit to pablogsal/cpython that referenced this pull request Oct 5, 2026
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.

profiling: flamegraph export fails with RecursionError on a deeply recursive program

2 participants