python / python/cpython

profiling.sampling heatmap reads non-regular and oversized files

Open
#153,838 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-profiling type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug description

The heatmap exporter in profiling.sampling reads source files named in a profile unconditionally via Path(filename).read_text(). It does not check whether the path is a regular file or whether the file size is reasonable.

When replaying a binary profile, a filename pointing to a device file (e.g. /dev/zero) causes unbounded memory growth. An oversized file has the same effect.

The fix adds an is_file() guard and a 10 MB size cap before reading, consistent with the binary reader hardening in gh-152718.

CPython versions tested on

main

Operating systems tested on

macOS

Linked PRs
  • gh-153839

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the profiling.sampling heatmap exporter where source paths are read with Path(filename).read_text(), and compare the binary reader hardening from gh-152718. Done means non-regular paths and files over 10 MB are not read; gh-153839 is already linked as the proposed work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.