Documentation

Miri.Concurrency.DataRace

Data-race clock state from pinned Miri #

This module ports the pure ordering, thread-clock, and per-memory-cell clock transitions in src/concurrency/data_race.rs at the pinned Miri revision. The allocation-level interpreter hooks, MIR integration, DedupRangeMap, diagnostic construction, and weak-memory store buffers are not modeled here. In particular, these definitions are source-backed state operations, not a standalone claim that a Rust program has been checked by Miri.

Miri Span values occur only in diagnostic attribution for the transitions ported here. They do not affect the vector-clock ordering or race decision, and are omitted from the Lean state. Atomic access sizes are represented as the exact u64 byte counts used by rustc_abi::Size.

The five orderings accepted for read/write atomic operations.

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      An atomic ordering accepted by either a read or a write.

      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          The ordering subset accepted by atomic loads.

          Instances For
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              The ordering subset accepted by atomic stores.

              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  The ordering subset accepted by atomic fences.

                  Instances For
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      A source-invalid ordering is made explicit where pinned Miri panics.

                      Instances For
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Per-thread vector-clock state, including all Miri fence and SC metadata.

                          • clock : VClock

                            The increasing happens-before clock.

                          • fenceAcquire : VClock

                            Clock to acquire on a later acquire fence.

                          • fenceRelease : VClock

                            Clock released by the most recent release fence.

                          • writeSeqCst : VClock

                            Per-thread SC-write metadata used by weak-memory emulation.

                          • readSeqCst : VClock

                            Per-thread SC-fence metadata used by weak-memory emulation.

                          Instances For
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              The source Default state: all five clocks are zero.

                              Equations
                              Instances For

                                Apply Miri's release-fence effect by copying the happens-before clock.

                                Equations
                                Instances For

                                  Apply Miri's acquire-fence effect by joining the accumulated acquire clock.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    Increment the known thread coordinate; timestamp overflow remains explicit.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For

                                      Join another thread's happens-before clock, leaving fence/SC metadata intact.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For

                                        Byte size from rustc_abi::Size, whose stored representation is u64.

                                        • value : Fin 18446744073709551616
                                        Instances For
                                          Equations
                                          Instances For
                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For
                                              def Miri.Concurrency.ByteSize.ofU64 (value : Nat) (h : value < 18446744073709551616) :

                                              Construct a byte size from an exact u64 value.

                                              Equations
                                              Instances For

                                                The mathematical byte count.

                                                Equations
                                                Instances For
                                                  @[simp]
                                                  theorem Miri.Concurrency.ByteSize.bytes_ofU64 (value : Nat) (h : value < 18446744073709551616) :
                                                  (ofU64 value h).bytes = value

                                                  Result used for the source's Result<(), DataRace> cell transitions.

                                                  Instances For
                                                    Equations
                                                    Instances For
                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For

                                                        Per-byte metadata attached to atomic memory.

                                                        • readVector : VClock

                                                          Most recent atomic reads by thread.

                                                        • writeVector : VClock

                                                          Most recent atomic writes by thread.

                                                        • syncVector : VClock

                                                          Clock released by the current modification/release sequence.

                                                        • One uniform size, or none after concurrent differently-sized reads.

                                                        Instances For
                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For

                                                            Initialize atomic metadata for the first access of a given size.

                                                            Equations
                                                            Instances For

                                                              Non-atomic write kinds counted by the detector, including lifetime writes.

                                                              Instances For
                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For

                                                                  Atomic accesses tracked by one memory cell.

                                                                  Instances For
                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For

                                                                      Access category used by Miri's race classifier.

                                                                      Instances For
                                                                        Equations
                                                                        Instances For
                                                                          Equations
                                                                          • One or more equations did not get rendered due to their size.
                                                                          Instances For

                                                                            Per-byte vector-clock state exactly corresponding to MemoryCellClocks fields.

                                                                            Instances For
                                                                              Equations
                                                                              • One or more equations did not get rendered due to their size.
                                                                              Instances For
                                                                                def Miri.Concurrency.MemoryCellClocks.new (allocationTimestamp : VTimestamp) (allocationIndex : VectorIdx) :

                                                                                Initialize one byte as a newly allocated non-atomic location.

                                                                                Equations
                                                                                Instances For

                                                                                  Whether the last non-atomic write happens before the supplied clock.

                                                                                  Equations
                                                                                  Instances For

                                                                                    Materialize the singleton write clock used by diagnostics.

                                                                                    Equations
                                                                                    Instances For

                                                                                      The source's size-state transition for an atomic access.

                                                                                      Equations
                                                                                      • One or more equations did not get rendered due to their size.
                                                                                      Instances For

                                                                                        A cell operation returns mutated states even when a race is detected. This matches the source's mutation-before-check order; execution then terminates at the caller.

                                                                                        Instances For
                                                                                          Equations
                                                                                          • One or more equations did not get rendered due to their size.
                                                                                          Instances For

                                                                                            Record an atomic load, then check whether the non-atomic write is ordered.

                                                                                            Equations
                                                                                            • One or more equations did not get rendered due to their size.
                                                                                            Instances For

                                                                                              Record an atomic write, then check prior non-atomic writes and reads.

                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For

                                                                                                Atomic load-acquire: detect the access and then acquire either the supplied weak-memory synchronization clock or the cell's release-sequence clock.

                                                                                                Equations
                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                Instances For

                                                                                                  Atomic load-relaxed: it accumulates the synchronization clock for a later acquire fence instead of joining the happens-before clock immediately.

                                                                                                  Equations
                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                  Instances For

                                                                                                    Atomic release store publishes the thread's happens-before clock.

                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For

                                                                                                      Atomic relaxed store breaks the previous release sequence, replacing it with the thread's release-fence clock.

                                                                                                      Equations
                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                      Instances For

                                                                                                        Release RMW extends (rather than replaces) the prior release sequence.

                                                                                                        Equations
                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                        Instances For

                                                                                                          Relaxed RMW extends the release sequence with the current release-fence clock.

                                                                                                          Equations
                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                          Instances For

                                                                                                            Non-atomic read: mark the current thread timestamp with the exact read kind, check non-atomic and atomic writes, and record the read clock.

                                                                                                            Equations
                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                            Instances For

                                                                                                              Non-atomic write: check prior writes, reads, and atomic accesses; on success replace the write timestamp, reset read clocks, and remove atomic metadata.

                                                                                                              Equations
                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                              Instances For

                                                                                                                A memory byte range, using the exact rustc_abi Size byte counts.

                                                                                                                Instances For
                                                                                                                  Equations
                                                                                                                  Instances For
                                                                                                                    Equations
                                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                                    Instances For

                                                                                                                      Sparse representation of DedupRangeMap<MemoryCellClocks>. Unmodified bytes share the allocation's initial cell; changed bytes are stored as overrides. Range boundaries and deduplication are storage details, while this representation preserves the per-byte values that the detector reads.

                                                                                                                      Instances For
                                                                                                                        Equations
                                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                                        Instances For

                                                                                                                          Read one byte; an absent override denotes its original allocation state.

                                                                                                                          Equations
                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                          Instances For

                                                                                                                            Replace one byte, preserving an explicit bounds failure.

                                                                                                                            Equations
                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                            Instances For

                                                                                                                              Allocation-level vector-clock state (AllocState in pinned Miri). The construction input is the allocation timestamp already selected by Miri's MemoryKind classification; that interpreter classification is outside this pure clock-state module.

                                                                                                                              Instances For
                                                                                                                                Equations
                                                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                                                Instances For
                                                                                                                                  def Miri.Concurrency.VClockAlloc.newAllocation (length : ByteSize) (allocationTimestamp : VTimestamp) (allocationIndex : VectorIdx) :

                                                                                                                                  Initialize every byte with the allocation write state, represented lazily.

                                                                                                                                  Equations
                                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                                  Instances For

                                                                                                                                    Read one byte's effective clock state.

                                                                                                                                    Equations
                                                                                                                                    Instances For

                                                                                                                                      Replace one byte's clock state.

                                                                                                                                      Equations
                                                                                                                                      Instances For

                                                                                                                                        Result of applying a per-cell race-detection hook to a byte range.

                                                                                                                                        Instances For
                                                                                                                                          Equations
                                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                                          Instances For

                                                                                                                                            Apply a source per-byte operation over a validated allocation range. Earlier bytes remain updated if a later byte reports a race, matching Miri's mutable range iteration order.

                                                                                                                                            Equations
                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                            Instances For

                                                                                                                                              Allocation-level non-atomic read hook, applying the exact per-byte read detector and preserving regular-read versus retag-read categorization.

                                                                                                                                              Equations
                                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                                              Instances For

                                                                                                                                                Allocation-level non-atomic write hook.

                                                                                                                                                Equations
                                                                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                                                                Instances For
                                                                                                                                                  def Miri.Concurrency.VClockAlloc.atomicRead (allocation : VClockAlloc) (range : AccessRange) (thread : ThreadClockSet) (index : VectorIdx) (accessSize : ByteSize) :

                                                                                                                                                  Allocation-level atomic-read race hook. Atomic ordering synchronization is applied by the corresponding per-cell load transition.

                                                                                                                                                  Equations
                                                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                                                  Instances For
                                                                                                                                                    def Miri.Concurrency.VClockAlloc.atomicWrite (allocation : VClockAlloc) (range : AccessRange) (thread : ThreadClockSet) (index : VectorIdx) (accessSize : ByteSize) :

                                                                                                                                                    Allocation-level atomic-write race hook.

                                                                                                                                                    Equations
                                                                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                                                                    Instances For
                                                                                                                                                      def Miri.Concurrency.VClockAlloc.atomicLoad (allocation : VClockAlloc) (range : AccessRange) (thread : ThreadClockSet) (index : VectorIdx) (accessSize : ByteSize) (ordering : AtomicReadOrd) (syncClock : Option VClock := none) :

                                                                                                                                                      Apply the source's ordering-specific atomic-load transition to every byte in a range. The optional clock overrides the cell's release-sequence clock, as it does when a weak-memory load selects a particular store.

                                                                                                                                                      Equations
                                                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                                                      Instances For
                                                                                                                                                        def Miri.Concurrency.VClockAlloc.atomicStore (allocation : VClockAlloc) (range : AccessRange) (thread : ThreadClockSet) (index : VectorIdx) (accessSize : ByteSize) (ordering : AtomicWriteOrd) :

                                                                                                                                                        Apply Miri's atomic-store ordering to every byte in a range.

                                                                                                                                                        Equations
                                                                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                                                                        Instances For
                                                                                                                                                          def Miri.Concurrency.VClockAlloc.atomicRmw (allocation : VClockAlloc) (range : AccessRange) (thread : ThreadClockSet) (index : VectorIdx) (accessSize : ByteSize) (ordering : AtomicRwOrd) :

                                                                                                                                                          Apply one atomic read-modify-write per byte, performing the read half before the write half and extending the release sequence according to the source ordering.

                                                                                                                                                          Equations
                                                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                                                          Instances For

                                                                                                                                                            Join the release-sequence clocks attached to every byte in a memory range, matching VClockAlloc::sync_clock. Uninitialized atomic metadata contributes the zero clock.

                                                                                                                                                            Equations
                                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                                            Instances For