Skip to content

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

Description

@tonghuaroot

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-profilingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions