dimensionalOS / dimensionalOS/dimos

macOS shared-memory attach/create race fails with OSError(22, 'Invalid argument')

Open
#4,128 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug mac
Dominant language
Python
Stars
4.5k
Forks
808
Avg merge
3d 5h
Merged PRs (30d)
233

Description

What happened?

Shared-memory concurrency/race handling fails reproducibly on macOS when a process attempts to attach/open shared memory during the creation window.

Two separate SHM tests reproduce the same underlying failure:

OSError(22, 'Invalid argument')

Both tests were automatically rerun twice by pytest and continued to fail.

Related shared-memory KeyError messages also appear during the failures.

What did you expect?

The shared-memory attach/open path should tolerate the creation race and successfully attach once the shared-memory segment is ready.

Concurrent shared-memory initialization should not fail with OSError(22, 'Invalid argument').

System

macOS, Apple Silicon / arm64

Robot / Sim / Hardware

None — shared-memory / IPC unit tests.

Steps to reproduce

Test 1:

uv run pytest \
  'dimos/protocol/pubsub/shm/test_ipc_factory.py::test_concurrent_open_survives_the_creation_window' \
  -vv -s --tb=long

Test 2:

uv run pytest \
  'dimos/utils/test_shm.py::test_attach_shm_waits_out_the_race' \
  -vv -s --tb=long

Environment

Install method: uv

Python: 3.12.13

pytest: 8.3.5

Nix: 2.35.2

Cargo: 1.98.1

Rustc: 1.98.1

DimOS branch / commit:

git branch --show-current
git rev-parse --short HEAD

Logs / screenshots

test_concurrent_open_survives_the_creation_window:

KeyError: '/tq_529d9d5b03d9_data'
KeyError: '/tq_0683e5465929_data'
KeyError: '/tq_0e2f9cbf4b59_data'

AssertionError: concurrent open failed: [OSError(22, 'Invalid argument')]
assert not [OSError(22, 'Invalid argument')]

1 failed, 2 rerun

test_attach_shm_waits_out_the_race:

KeyError: '/dimos_test_dcbb21ec854b'
KeyError: '/dimos_test_41936f37a50f'
KeyError: '/dimos_test_16f9ccb17e16'

AssertionError: attacher did not survive the window: [OSError(22, 'Invalid argument')]
assert [OSError(22, 'Invalid argument')] == [65536]

1 failed, 2 rerun

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.

Research direction

Start by running the two reproductions: dimos/protocol/pubsub/shm/test_ipc_factory.py::test_concurrent_open_survives_the_creation_window and dimos/utils/test_shm.py::test_attach_shm_waits_out_the_race with the provided uv command. Trace the shared-memory attach/open path used by these tests and make the creation window tolerate macOS failures. Done means both tests reliably pass without OSError(22) or related KeyError messages.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.