astral-sh / astral-sh/python-build-standalone
Memory leak on macOS
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 314
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 27
Description
The readline module included with UV python builds leaks memory, resulting in unexpected behavior for all inheriting packages (including Pytest most notably).
To reproduce, create a uv venv on macOS with python versions `3.10`, `3.11`, `3.12`, or `3.13`. Then, run a leak checker on `import readline`
```bash
> sudo leaks --atExit -- python -c "import readline" | grep bytes
Process 5364: 1 leak for 16 total leaked bytes.
1 (16 bytes) ROOT LEAK: [16]
```
Running the (roughly) equivalent command on linux appears not to leak memory:
```bash
> valgrind --leak-check=full python -c "import readline"
==2484992== LEAK SUMMARY:
==2484992== definitely lost: 0 bytes in 0 blocks
==2484992== indirectly lost: 0 bytes in 0 blocks
==2484992== possibly lost: 0 bytes in 0 blocks
==2484992== still reachable: 500,336 bytes in 199 blocks
==2484992== suppressed: 0 bytes in 0 blocks
```
This only seems to be the case in UV python distros - I can confirm that homebrew python versions do not leak memory.
See pytest-dev/pytest#13636 for the original reference.
Contributor guide
Assessment
This issue has not been assessed yet.