python / python/cpython

`multiprocessing.Pool` fails if command has a long list of arguments (regression in 3.14.3, 3.13.12)

Đang mở
#144,503 15 bình luận 0 reaction 1 người được giao Xem trên GitHub

@gpshead đang làm issue này rồi.

Từ ngày 7/4/2026.

3.13 3.14 3.15 stdlib topic-multiprocessing type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Bug report

Bug description:

A multiprocessing pool can fail to start when the command that starts the pool was ran with a lot of arguments.

Minimal working example:

# mwe.py
import multiprocessing
if __name__ == "__main__":
    with multiprocessing.Pool():
        pass

Run this using the following script:

#!/bin/bash

PAGE_SIZE=$(getconf PAGE_SIZE)
MAX_ARG_STRLEN=$((32 * PAGE_SIZE))
COUNT=$((MAX_ARG_STRLEN / 100 ))
echo $COUNT
yes "$(printf 'a%.0s' {1..100})" | head -n $COUNT | xargs python3 mwe.py

What this will do is effectively run the following:

python3 mwe.py aaa..a aaa..a aaa..a ... aaa.a

The Python process itself launches correctly, as each argument is only 100 bytes long (way under the maximum argument length of MAX_ARG_STRLEN).
The creation of the multiprocessing pool however fails, because the sys.argv variable is taken, and used to build a single string in multiprocessing.forkserver.ForkServer.ensure_running here: https://github.com/python/cpython/blob/d5cb9f6a9b6f48cc08c4422259498d4fd023357a/Lib/multiprocessing/forkserver.py#L175.

This is caused by a recent change: https://github.com/python/cpython/pull/143717, which was also backported to 3.13 and 3.14. (It works on 3.14.2, fails on 3.14.3).

CPython versions tested on:

3.15, 3.14

Operating systems tested on:

Linux

Linked PRs
  • gh-144508
  • gh-148194
  • gh-148195
  • gh-148196

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.