Skip to content

[3.14] gh-144503: Pass sys.argv to forkserver as real argv elements (GH-148194)#148195

Merged
gpshead merged 1 commit intopython:3.14from
gpshead:backport-5e9d90b-3.14
Apr 7, 2026
Merged

[3.14] gh-144503: Pass sys.argv to forkserver as real argv elements (GH-148194)#148195
gpshead merged 1 commit intopython:3.14from
gpshead:backport-5e9d90b-3.14

Conversation

@gpshead
Copy link
Copy Markdown
Member

@gpshead gpshead commented Apr 7, 2026

Avoid embedding the parent's sys.argv into the forkserver -c command string via repr(). When sys.argv is large (e.g. thousands of file paths from a pre-commit hook), the resulting single argument could exceed the OS per-argument length limit (MAX_ARG_STRLEN on Linux, typically 128 KiB), causing posix_spawn to fail and the parent to observe a BrokenPipeError.

Instead, append the argv entries as separate command-line arguments after -c; the forkserver child reads them back as sys.argv[1:]. This cannot exceed any limit the parent itself did not already satisfy.

Regression introduced by gh-143706 / 298d544. present in 3.14.3
(cherry picked from commit 5e9d90b)

…ents (pythonGH-148194)

Avoid embedding the parent's sys.argv into the forkserver -c command
string via repr().  When sys.argv is large (e.g. thousands of file
paths from a pre-commit hook), the resulting single argument could
exceed the OS per-argument length limit (MAX_ARG_STRLEN on Linux,
typically 128 KiB), causing posix_spawn to fail and the parent to
observe a BrokenPipeError.

Instead, append the argv entries as separate command-line arguments
after -c; the forkserver child reads them back as sys.argv[1:].  This
cannot exceed any limit the parent itself did not already satisfy.

Regression introduced by pythongh-143706 / 298d544.
(cherry picked from commit 5e9d90b)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

1 participant