From da0c457ff746899f2bf3960626376ee2baaa2b82 Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 9 Jun 2026 20:22:23 -0400 Subject: [PATCH] =?UTF-8?q?Document=20`SharedMemory`=20=C3=97=20`subint=5F?= =?UTF-8?q?forkserver`=20incompat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New `ai/conc-anal/` doc: `mp.SharedMemory` is fork-without-exec unsafe — child inherits parent's `resource_tracker` fd → EBADF on first shm op; leaked `/shm_list` cascades `FileExistsError` across parametrize variants. Canonical CPython issue class, NOT a tractor bug. Includes two longer-term mitigation paths (reset inherited tracker fd vs migrate off `mp.shared_memory`). Also, update `tests/test_shm.py`: - comment out `subint_forkserver` from skip list - rewrite reason with precise failure-mode descriptions + link to the analysis doc (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code (cherry picked from commit c99d475d0317f9e0fbbb4d51abc299c90e4d965a) (factored: dropped spawn-backend-only paths: ai/conc-anal/subint_forkserver_mp_shared_memory_issue.md) --- tests/test_shm.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_shm.py b/tests/test_shm.py index 61bcdee2..8ea43457 100644 --- a/tests/test_shm.py +++ b/tests/test_shm.py @@ -16,14 +16,18 @@ from tractor.ipc._shm import ( pytestmark = pytest.mark.skipon_spawn_backend( 'subint', - 'subint_forkserver', + # 'subint_forkserver', reason=( 'subint: GIL-contention hanging class.\n' 'subint_forkserver: `multiprocessing.SharedMemory` ' - 'has known issues with fork-without-exec (mp\'s ' - 'resource_tracker and SharedMemory internals assume ' - 'fresh-process state). RemoteActorError surfaces from ' - 'the shm-attach path. TODO, put issue link!\n' + 'is fork-without-exec unsafe — child inherits parent\'s ' + '`resource_tracker` fd → EBADF on first shm op ' + '(`test_child_attaches_alot`); leaked `/shm_list` from ' + 'a "passing" run cascades into `FileExistsError` across ' + 'parametrize variants (`test_parent_writer_child_reader`). ' + 'Canonical CPython issue class, NOT a tractor bug; full ' + 'tracker doc:\n' + 'ai/conc-anal/subint_forkserver_mp_shared_memory_issue.md' ) )