]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-144503: Pass sys.argv to forkserver as real argv elements (GH-148194) ...
authorGregory P. Smith <68491+gpshead@users.noreply.github.com>
Tue, 7 Apr 2026 06:19:40 +0000 (23:19 -0700)
committerGitHub <noreply@github.com>
Tue, 7 Apr 2026 06:19:40 +0000 (23:19 -0700)
commit3038ee956e3f7dda10e694764b4e7d4ae7294057
tree8e3dad0af1c291febd0acdb4d1d0f52be79ab305
parentc358b89d240cb193c007e38f9f643b2a3d9f5de6
[3.13] gh-144503: Pass sys.argv to forkserver as real argv elements (GH-148194) (#148196)

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 / 298d5440eb8.
(cherry picked from commit 5e9d90b615b94469081b39a7b0808fea86c417be)
Lib/multiprocessing/forkserver.py
Lib/test/_test_multiprocessing.py
Lib/test/mp_preload_large_sysargv.py [new file with mode: 0644]
Misc/NEWS.d/next/Library/2026-04-07-01-04-00.gh-issue-144503.argvfs.rst [new file with mode: 0644]