Phase 5: race detector (P5-6) and the atomic_stats reference program (P5-9b)

Dynamic data-race detector for ordinary memory: vector clocks are the
task-keyed part of the weak-memory views, so happens-before follows every
synchronization edge already modelled; per-cell shadows with path
granularity. Enabled for every conformance run test (433, no false
positive); a unit test shows an unverified racy program caught on every
schedule. Reference program atomic_stats in .aji and hand-written AIR by an
independent author (equivalent:, 30 schedule seeds). Author feedback:
07a clarifications; Q-025 (no array construction) logged.
This commit is contained in:
dev committed 2026-10-06 08:11:25 +03:00
1 parent 4242132b2a
commit 0879b9497b
10 files changed
+481 -10

No files matched your search

+5
View File
@@ -27,6 +27,7 @@ Status values: `open`, `resolved`.
| Q-019 | resolved | P3 | Non-terminating programs in test tooling |
| Q-020 | resolved | P2 | Size bound for SSA array values |
| Q-024 | resolved | P5 | Memory-model clarifications found by the independent oracle |
| Q-025 | open | — | No array construction from element values in AIR |
## Q-001 — Text AIR grammar
@@ -197,3 +198,7 @@ Points 1–3 and 5 are editorial. Point 4 fixes FIFO, which spec 04 §38 already
- capacity-based synchronization would be a separate feature by RFC.
5. The C++20 release sequence, stated explicitly.
## Q-025 — No array construction from element values in AIR
Found by the independent author of `program_atomic_stats.air` (P5-9b). AIR has `array.splat` but no way to build an array from distinct element values. A six-element constant array costs a mutable borrow, six `borrow.index`/`store`/`borrow.end` triples and six index constants. `.aji` has the same gap: it has `[e; N]` but no array literal. The options are an `array.make T (%a, %b, …)` instruction (a value constructor like `struct.make`) with an `.aji` literal `[a, b, c]`, or no change. This is a convenience question, not a correctness one. It is not urgent, and any RFC for it must report its agent-complexity cost.
@@ -83,12 +83,12 @@ Phase 4 commit frozen (tag p4-frozen)
| P5-3 | done | AIR parse/print, types (linear `atomic<T>`, AtomicScalar, not IslandSafe), ordering tables, `E4202` | P5-1a | `src/air/`, `src/verifier/` | `E4201` accept/reject for every operation and every cmpxchg success/failure pair; `E4202`; `E1001`, `E2111`, `E0006` cases |
| P5-4 | done | `atomic` / `atomic.weak` effects (spec 05 §13); weak sites in `aji report` | P5-3 | verifier + report | each non-`seq_cst` ordering without `atomic.weak` is `E3101`; `seq_cst` needs only `atomic`; weak sites listed |
| P5-5 | done | Interpreter: atomic cells with message histories, views, weak reads drawn from the schedule stream; atomic operations are scheduling points | P5-3 | `src/interp/` | sound on the corpus and the differential test; no extra draw without weak accesses; existing records unchanged |
| P5-6 | todo | Happens-before tracking and dynamic race detector (validates the verifier) | P5-5 | `src/interp/` | any race the verifier missed aborts the test run with a diagnostic |
| P5-6 | done | Happens-before tracking and dynamic race detector (validates the verifier) | P5-5 | `src/interp/` | any race the verifier missed aborts the test run with a diagnostic |
| P5-7 | done | Exhaustive bounded exploration of schedules and weak-read choices | P5-5 | `src/interp/` | for each litmus test, the outcome set observed equals the oracle's allowed set exactly |
| P5-8 | dropped | Record and replay: moved to Phase 8 (P8-10) by RFC 0015 D13 | — | — | — |
| P5-9 | done | Litmus runner and differential test (random small programs; interpreter outcomes ⊆ oracle outcomes) | P5-7 | `tests/litmus/`, `zig build litmus` | all corpus tests pass with exact equality; differential test in CI |
| P5-9a | done | `.aji` layer 10 (spec 15 §12), Quick Reference subsection after mutexes, source coverage rows, bundle measurement | P5-4 | `src/frontend/`, `docs/agent/` | `.aji` run/reject tests for every row; Quick Reference excerpts checked; growth recorded against RFC 0015's estimate |
| P5-9b | todo | Reference program with atomics in AIR (written by an independent author from the spec) and `.aji`, with `equivalent:` | P5-9a | `tests/conformance/` | passes under all stress modes and under `aji explore` with no forbidden outcome |
| P5-9b | done | Reference program with atomics in AIR (written by an independent author from the spec) and `.aji`, with `equivalent:` | P5-9a | `tests/conformance/` | passes under all stress modes and under `aji explore` with no forbidden outcome |
| P5-10 | todo | Phase exit review | all | plan status | exit criterion passes |
## Regression gate (P5-0)
+3 -2
View File
@@ -257,7 +257,7 @@ Allowed only in functions that declare the effect `unsafe` or are `trusted` (`E6
## Feature `tasks`
Types `scope` and `task<T>` (linear, function-bound), instructions `task.scope.begin`, `task.spawn %s, @f(…)`, `task.join`, `task.cancel`, `task.cancelled`, `task.scope.end`; loans, `Send`/`Share` and the scheduler: spec 04 §33–§36.
Types `scope` and `task<T>` (linear, function-bound), instructions `task.scope.begin`, `task.spawn %s, @f(…)`, `task.join`, `task.cancel`, `task.cancelled`, `task.scope.end`; loans, `Send`/`Share` and the scheduler: spec 04 §33–§36. In a module that declares `cancellation`, `task.join` waits and requires the effect `task.wait` (spec 04 §37.4); `task.spawn` always requires `task.spawn`.
## Features `cancellation`, `channels`, `sync`
@@ -281,7 +281,8 @@ Status `reserved` until it is published with its implementation (P5-2a). Its con
- type: linear `atomic<T>` for AtomicScalar `T`;
- instructions: `atomic.new`, `atomic.take`, `atomic.load.<o>`, `atomic.store.<o>`, `atomic.<rmw>.<o>` (`xchg`, `add.wrap`, `sub.wrap`, `and`, `or`, `xor`), `atomic.cmpxchg.<s>.<f>` (two results), `atomic.fence.<o>`;
- the contract table: spec 04 §42;
- the contract table: spec 04 §42. `atomic.cmpxchg` has two results, in this order: the value read and a `bool` that is `true` when it exchanged;
- `atomic<T>` is `Share`, so one `ref<atomic<T>>` may be lent to any number of tasks (spec 04 §35);
- the orderings: spec 04 §24;
- the memory model: spec 04 §20–§30;
- effects: spec 05 §13.