# Concurrency Litmus Tests Litmus tests for the memory model of spec 04 §20–§30 (RFC 0015). They are semantic tests for the oracle, the interpreter and native backends. The tests do not define the model; spec 04 §20 does. They are its consequences, and the normative conformance corpus for the interpreter (spec 04 §20.5). **Status:** normative conformance corpus of the Aji 0.1 atomic model (owner, 2026-10-06; spec 04 §20.5). The independent oracle's allowed set equals the stated set for all 20 tests (`python3 tools/litmus/check.py`). Changing a published test's sets changes the memory model and requires an RFC. New tests that only cover existing axioms may be added. The sets below were derived by hand from the axioms. The test files are `tests/litmus/*.lit` (format: `tests/litmus/README.md`), where every allowed set is written out in full. P5-1a makes the corpus normative: `tools/litmus/check.py` confirms every set against the independent oracle `tools/litmus/enumerate.py`, and the owner reviews the result. When the enumerator, the interpreter and a stated set disagree, the cause is diagnosed (spec 04 §20.5). A set is never edited to match a tool without a diagnosis. ## Rules - Each test states its **allowed** outcome set and its **forbidden** outcome set. A test never states a single expected result. - **Oracle:** the enumerator's allowed set MUST equal the stated allowed set. - **Interpreter:** - under exhaustive exploration, the observed outcomes MUST equal the allowed set, for these tests; - for any program, under any exploration, no outcome outside the allowed set may appear. - Unless stated otherwise: - locations start at 0; - tasks run in parallel under one scope; - `rlx`, `acq`, `rel`, `ar`, `sc` abbreviate the five orderings. ## Notation - `‖` separates tasks. - A tuple lists the reading registers in program order of the tasks, task by task. - `final x` is the value `atomic.take` reads after all joins. ## Corpus | Test | Shape | Allowed | Forbidden | |---|---|---|---| | MP rel/acq | `x=1 rlx; y=1 rel` ‖ `r0=y acq; r1=x rlx` | (0,0) (0,1) (1,1) | (1,0) | | MP rlx | all `rlx` | all four | — | | MP fences | `x=1 rlx; fence rel; y=1 rlx` ‖ `r0=y rlx; fence acq; r1=x rlx` | (0,0) (0,1) (1,1) | (1,0) | | SB rlx | `x=1; r0=y` ‖ `y=1; r1=x`, all `rlx` | all four | — | | SB rel/acq | stores `rel`, loads `acq` | all four, including (0,0) | — | | SB sc | all `sc` | (0,1) (1,0) (1,1) | (0,0) | | SB fences | `rlx` accesses, `fence sc` between store and load on both sides | (0,1) (1,0) (1,1) | (0,0) | | LB rlx | `r0=x; y=1` ‖ `r1=y; x=1`, all `rlx` | (0,0) (0,1) (1,0) | (1,1), a consequence of NO-THIN-AIR | | IRIW acq | `x=1 rel` ‖ `y=1 rel` ‖ `r0=x acq; r1=y acq` ‖ `r2=y acq; r3=x acq` | all 16 tuples, including (1,0,1,0) | — | | IRIW sc | all `sc` | every tuple except (1,0,1,0) | (1,0,1,0) | | CoRR | `x=1 rlx` ‖ `r0=x rlx; r1=x rlx` | (0,0) (0,1) (1,1) | (1,0) | | CoWW | `x=1 rlx; x=2 rlx`, final `x` | 2 | 1 | | relaxed counter | 2 tasks × 2 `add.wrap(x,1) rlx`, final `x` | 4 | 2, 3 | | CAS exclusion | `r0=cas.rlx.rlx(x,0→1)` ‖ `r1=cas.rlx.rlx(x,0→2)` (old values) | (0,1) (2,0) | (0,0) | | CAS failure acquire | `d=1 rlx; f=1 rel` ‖ `r0=cas.acq.acq(f,0→5); r1=d rlx` | (0,0) (0,1) (1,1) | (1,0) | | CAS failure relaxed | as above with `cas.acq.rlx` | (0,0) (0,1) (1,0) (1,1) | — | | release sequence | `d=1 rlx; f=1 rel` ‖ `add.wrap(f,2) rlx` ‖ `r0=f acq; r1=d rlx` | (0,0) (0,1) (1,1) (2,0) (2,1) (3,1) | (1,0) (3,0) | | channel handoff | `x=1 rlx; send(t)` ‖ `recv; r0=x rlx` | (1) | (0) | | mutex handoff | `lock; x=1 rlx; f=1 rlx; unlock` ‖ `lock; r0=f rlx; r1=x rlx; unlock` | (0,0) (1,1) | (1,0) (0,1) | | spawn/join | `x=1 rlx`; spawn ‖ child: `r0=x rlx; x=2 rlx`; after join `r1=x rlx` | (1,2) | (0,2) (1,1) | ## Rejected programs These are verifier tests, not outcome tests. | Test | Program | Code | |---|---|---| | ordinary race | two tasks `store` the same ordinary `u64` through overlapping borrows | `E4101` | | mixing | ordinary `load` through `ref>` | `E4202` | | invalid ordering | `atomic.load.release` | `E4201` | | invalid failure ordering | `atomic.cmpxchg.relaxed.acquire` | `E4201` | | take while lent | `atomic.take` of a cell whose `ref` is lent to a live task | `E4101` |