profiling.sampling heatmap reads non-regular and oversized files
Nobody has claimed this yet.
- 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
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 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