python / python/cpython

`OSError: AF_UNIX path too long` regression in `forkserver`

Open
#149,527 4 comments 0 reactions 1 assignee View on GitHub

@picnixz is already working on this.

Since May 9, 2026.

3.13 3.14 3.15 stdlib topic-multiprocessing type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

Since fd81246bd55e4fab1976a7cca3e5d42582dbdac0 (in 3.14 as e590f007ed8b0268c40bcae445d6b50e06b00960), we're seeing Gentoo Portage randomly fail with:

Traceback (most recent call last):
  File "/usr/lib/portage/python3.14/ebuild-ipc.py", line 303, in <module>
    sys.exit(ebuild_ipc_main(sys.argv[1:]))
             ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/lib/portage/python3.14/ebuild-ipc.py", line 299, in ebuild_ipc_main
    return ebuild_ipc.communicate(args)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/portage/python3.14/ebuild-ipc.py", line 151, in communicate
    lock_obj = portage.locks.lockfile(self.ipc_lock_file, unlinkfile=True)
  File "/usr/lib/python3.14/site-packages/portage/locks.py", line 184, in lockfile
    lock = _lockfile_iteration(
        mypath,
    ...<3 lines>...
        flags=flags,
    )
  File "/usr/lib/python3.14/site-packages/portage/locks.py", line 314, in _lockfile_iteration
    locking_method = _get_lock_fn()
  File "/usr/lib/python3.14/site-packages/portage/locks.py", line 96, in _get_lock_fn
    if _test_lock_fn(_lockf_test_lock_fn):
       ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/site-packages/portage/locks.py", line 128, in _test_lock_fn
    proc.start()
    ~~~~~~~~~~^^
  File "/usr/lib/python3.14/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
                  ~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.14/multiprocessing/context.py", line 230, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/lib/python3.14/multiprocessing/context.py", line 306, in _Popen
    return Popen(process_obj)
  File "/usr/lib/python3.14/multiprocessing/popen_forkserver.py", line 35, in __init__
    super().__init__(process_obj)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/lib/python3.14/multiprocessing/popen_fork.py", line 20, in __init__
    self._launch(process_obj)
    ~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/lib/python3.14/multiprocessing/popen_forkserver.py", line 51, in _launch
    self.sentinel, w = forkserver.connect_to_new_process(self._fds)
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/lib/python3.14/multiprocessing/forkserver.py", line 89, in connect_to_new_process
    self.ensure_running()
    ~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.14/multiprocessing/forkserver.py", line 167, in ensure_running
    listener.bind(address)
    ~~~~~~~~~~~~~^^^^^^^^^
OSError: AF_UNIX path too long

Apparently in this case the resulting path was:

/tmp/mgorny-dev-scripts/portage/dev-python/trove-classifiers-2026.5.7.17/temp/pymp-o2g23iqr/sock-d559f6e62fa1

Note that tempfile.mktemp() used to append 8 ASCII characters, while this logic appends 12 hex digits, so the logic introduced in 1a07a01014bde23acd2684916ef38dc0cd73c2de would be off by 4 now.

CPython versions tested on:

3.14, CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-149597

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.