Spec issues & errata · defect of the text · docs/spec-issues/67-memory-model-rmw-cycle.md
67. §29 Memory Model: overlapping-RMW ValueOfReadEvent cycle non-termination, unquantified reads-bytes-from, and HostEventSet
- Location
- §29.5.4 ComposeWriteEventBytes (
#sec-composewriteeventbytes), step 3.d.ii; §29.5.5 ValueOfReadEvent (#sec-valueofreadevent); §29.6.2 reads-bytes-from (#sec-reads-bytes-from); §29.6.5 synchronizes-with (#sec-synchronizes-with), first bullet; §29.7.5 Valid Executions (#sec-valid-executions); §29.5.3 HostEventSet (#sec-hosteventset) and §29.6.4 host-synchronizes-with (#sec-host-synchronizes-with). - Kind
- non-terminating mutual recursion on candidate executions, unquantified relation variable, and set-domain contradiction.
- Model erratum
MemoryModelRMWCycleAndRbf, baked-in SpecTec reading proposed (layernone,spec/spectec/prose/07-memory-model.spectec). SpecTec definesComposeandValueOfas a mutual inductive least fixpoint (so cyclic RMW byte reads evaluateValidChosenReadstoFalseinstead of diverging), existentially quantifiesrbf : Rbf(E)inValid, convertsTear Free Readsstep 1.a.i'sAssert:into a boolean conjunct, and definesHostSyncoverinHost.- Upstream
- Checked 2026-11-19: none found for the RMW cycle or
HostEventSetdomain; PR #3321 (merged 2024-05, commit1babaf809), "Editorial: Rework memory model relations", removed[[ReadsBytesFrom]]from Candidate Execution Records while leavingreads-bytes-fromunquantified in §29.7.5. - On this site
MemoryModelRMWCycleAndRbfon Spec issues & errata (defect of the text; SpecTec bakes in the proposed reading)
Text
ComposeWriteEventBytes (§29.5.4):
ii. Let bytes be ValueOfReadEvent(execution, writeEvent).
synchronizes-with (§29.6.5):
For events readEvent and writeEvent, writeEvent synchronizes-with readEvent in execution if readEvent reads-from writeEvent in execution, readEvent.[[Order]] is seq-cst, writeEvent.[[Order]] is seq-cst, and readEvent and writeEvent have equal memory ranges.
Valid Executions (§29.7.5):
A candidate execution execution is a valid execution (or simply an execution) if all of the following are true.
execution admits a happens-before Relation that is a strict partial order.
HostEventSet (§29.5.3) vs host-synchronizes-with (§29.6.4):
1. Return a new Set containing all elements of EventSet(execution) that are not in SharedDataBlockEventSet(execution).
For a candidate execution execution, its host-synchronizes-with Relation is a host-provided strict partial order on host-specific Memory events that satisfies at least the following.
If eventA host-synchronizes-with eventB in execution, HostEventSet(execution) contains eventA and eventB.
Problem
- Non-terminating
ValueOfReadEvent↔ComposeWriteEventBytesrecursion on unequal overlapping RMWs.reads-bytes-fromonly forbids direct 1-cycles (_readEvent_ is not in _writes_), not 2-cycles (rmw1reads byte 0 fromrmw2andrmw2reads byte 0 fromrmw1). Whenrmw1(e.g. 2-byteUint16ArrayRMW on[0, 2)) andrmw2(4-byteUint32ArrayRMW on[0, 4)) have unequal overlapping ranges, §29.6.5synchronizes-withstep 1.c does not order them! Thushappens-beforeremains a strict partial order,Coherent Readsholds,Tear Free Readsholds, andSequentially Consistent Atomicsholds — yetValid Chosen ReadsinvokesValueOfReadEvent, which diverges in infinite mutual recursion without returning*true*or*false*! - Unquantified
reads-bytes-fromin §29.7.5. PR #3321 removed[[ReadsBytesFrom]]from Candidate Execution Records, yet §29.7.5Valid Executionsquantifieshappens-beforewithout quantifying "admits a reads-bytes-from function"! HostEventSetincludesSynchronizeevents. §29.1 partitions Memory events into Shared Data Block, Synchronize (EnterCriticalSection/LeaveCriticalSection), and host-specific events, yetHostEventSetincludes Synchronize events, contradicting §29.6.4's header.
Examples
None run (the memory model is a declarative relation in lean/Ecma/MemoryModel.lean); SpecTec's inductive ValueOf
rejects cyclic RMW reads cleanly.
Proposed wording
Require reads-bytes-from to be acyclic across RMW events (or order overlapping RMWs in synchronizes-with), quantify
reads-bytes-from in §29.7.5 Valid Executions, and exclude Synchronize events from HostEventSet (§29.5.3).
test262
None (test262 does not test formal §29 candidate-execution edge cases).