Skip to content

executor: mount isolated POSIX shared memory per action - #34

Open
zbarsky-openai wants to merge 1 commit into
hermeticbuild:mainfrom
zbarsky-openai:zbarsky/per-action-posix-shared-memory
Open

zbarsky-openai wants to merge 1 commit into
hermeticbuild:mainfrom
zbarsky-openai:zbarsky/per-action-posix-shared-memory

Conversation

@zbarsky-openai

@zbarsky-openai zbarsky-openai commented Aug 24, 2026

Copy link
Copy Markdown

Python multiprocessing fails inside an action sandbox while creating a POSIX
named semaphore:

executor = ProcessPoolExecutor(max_workers=5, mp_context=multiprocessing.get_context("spawn"))
...
self._semlock = _multiprocessing.SemLock(...)
FileNotFoundError: [Errno 2] No such file or directory

Create /dev/shm alongside each action's existing base directories and mount a
private 64 MiB tmpfs after entering its mount namespace. Keep the mount
nosuid,nodev,noexec, give it the standard sticky world-writable mode, and
perform the mount before dropping sandbox privileges. Extend the existing base
directory test to cover the new mount point.

The failure was reproduced remotely with
//project/oai_sandbox:pytest -k test_get_minijail_concurrent_calls_only_one_download
using Bazel 9.3.0-actiond-dzbarsky14.

After rebuilding the guest and preserving the existing CAS-maintenance wrapper, the same test passes remotely with 300 submitted process-pool calls (one real remote test execution; invocation a36afe32-8b71-4ccf-ab6c-47f357cb77d8).

Python multiprocessing fails inside an action sandbox while creating a POSIX
named semaphore:

```text
executor = ProcessPoolExecutor(max_workers=5, mp_context=multiprocessing.get_context("spawn"))
...
self._semlock = _multiprocessing.SemLock(...)
FileNotFoundError: [Errno 2] No such file or directory
```

Create `/dev/shm` alongside each action's existing base directories and mount a
private 64 MiB tmpfs after entering its mount namespace. Keep the mount
`nosuid,nodev,noexec`, give it the standard sticky world-writable mode, and
perform the mount before dropping sandbox privileges. Extend the existing base
directory test to cover the new mount point.

The failure was reproduced remotely with
`//project/oai_sandbox:pytest -k test_get_minijail_concurrent_calls_only_one_download`
using Bazel `9.3.0-actiond-dzbarsky14`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant