profiling: flamegraph export fails with RecursionError on a deeply recursive program
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
The sampling profiler's flamegraph export (profiling.sampling.stack_collector.FlamegraphCollector.export) builds the flamegraph tree with a recursive walk (convert_children) and then serializes it with json.dumps — both recurse to the depth of the deepest sampled stack. The remote unwinder captures up to MAX_FRAMES (1536) frames, but export runs at the default recursion limit (1000), so profiling a program that recurses deeper than ~1000 makes export() raise RecursionError and write no flamegraph. Both --flamegraph and --diff-flamegraph are affected (the diff collector inherits export).
Reachable when profiling a program that raised its own recursion limit and recurses deeply (recursive-descent parsers, tree/graph walkers, deep serializers).
CPython versions tested on:
CPython main
Operating systems tested on:
Linux, macOS
Linked PRs
- gh-156546
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in profiling/sampling/stack_collector.py at FlamegraphCollector.export and its convert_children walk. Reproduce with a deeply recursive program whose recursion limit exceeds the captured stack depth, using both --flamegraph and --diff-flamegraph. Done means both export paths produce a flamegraph without RecursionError; review linked PR gh-156546 for work already underway.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100