astral-sh / astral-sh/python-build-standalone

Python scripts do not work under valgrind, including codspeed

Open
#508 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
4.4k
Forks
314
Avg merge
1d 9h
Merged PRs (30d)
27

Description

This is https://bugs.kde.org/show_bug.cgi?id=396415 , but opening it here just for tracking/visibility. When running a script under valgrind mis-reports /proc/self/exe as the path to the script itself instead of the path to the script interpreter. This means that, at least on glibc/Linux, the `$ORIGIN`-relative library paths that are used by python-build-standalone don't get resolved correctly for scripts installed in a different directory to the Python interpreter (notably, those installed in a venv), and the Python interpreter fails to launch.

The minimal reproduction is something like `valgrind --tool=none some/venv/bin/pytest` (or just plain `valgrind`).

This was reported specifically as `codspeed run pytest` (invoked by CodSpeedHQ/action in GHA) not working. CodSpeed internally uses valgrind.

A workaround is to invoke the interpreter directly instead of using a script, either with an appropriate `python -m` command (e.g. `python -m pytest`), or by passing the script as an argument to the interpreter (e.g., `python some/venv/bin/pytest`).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.