Documentation

Miri.Concurrency.GlobalState

Ordinary-lifecycle reuse boundary: thread termination publishes the old release snapshot and then increments its own vector coordinate. Join acquires only the snapshot, so a live caller can remain one tick behind the terminated candidate. A synthetic safe candidate tests the hook/predicate, not reachability through ordinary spawn/join. See MiriTests/DataRace/ThreadClockReuseReachability.lean.

Pinned Miri global vector-clock state #

This module models the GlobalState thread/clock bookkeeping and synchronization hooks in src/concurrency/data_race.rs. It preserves the thread-to-vector mapping, re-use set, termination snapshots, all five per-thread clocks, SC fence/write clocks, race-detection flags, and configuration bits. A reusable index is selected through an explicit choice from the exact set of candidates accepted by Miri's predicate; the source uses FxHashSet iteration order, which is an implementation detail, so this relation exposes every safe member instead of inventing a stable order.

The methods here do not implement interpreter callbacks, TLS cleanup, atomic memory-cell validation, allocation metadata, diagnostics, or scheduler actions. threadTerminated is called only after the caller has completed Miri's prior TLS cleanup and marked the active thread terminated. Such cross-subsystem actions remain explicit preconditions at the integration boundary.

Additional source metadata retained for every ever-created ThreadId.

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          structure Miri.Concurrency.SyncOperationBodyResult (External Error Value : Type) :

          State returned by an operation body executed under Miri's synchronized operation wrapper. The body may update clocks and external memory before returning an error, so those states remain available on the error path.

          Instances For

            Pinned Miri fields needed by concurrency synchronization and reuse.

            Instances For
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                structure Miri.Concurrency.SyncOperationTransition (Error External Value : Type) :

                Result of maybe_perform_sync_operation. none means Miri's single-threaded fast path skipped the body entirely.

                Instances For
                  def Miri.Concurrency.GlobalState.initial (trackOutdatedLoads weakMemory : Bool) :
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      Equations
                      Instances For
                        def Miri.Concurrency.GlobalState.maybePerformSyncOperation {External Error Value : Type} (state : GlobalState) (threads : ThreadManager) (external : External) (body : VectorIdx → ThreadClockSet → External → SyncOperationBodyResult External Error Value) :
                        SyncOperationTransition Error External Value

                        Run the same callback boundary as Miri's maybe_perform_sync_operation. The callback is skipped when multithreaded tracking is off. Otherwise its clock and external-state mutations survive failure, and a normal true result causes one clock increment after the callback.

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

                          Every candidate accepted by the source's all-clocks predicate, in the existing collection's order. Selection remains explicit because the original FxHashSet traversal order is not a language-level semantic guarantee.

                          Equations
                          Instances For

                            Apply Miri's thread-created hook after the ThreadManager has created the child. reuseChoice must be a safe candidate when any exist, and must be none when none exist. This preserves Miri's join-before-increment ordering.

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

                              Acquire a clock into the active thread without incrementing its timestamp.

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

                                Release snapshot: return the old clock and increment the active clock.

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

                                  Thread termination hook. The manager must already have marked the active thread Terminated and completed the preceding TLS cleanup effects.

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

                                    Join a terminated thread. The caller supplies the post-join ThreadManager, whose live-thread count controls Miri's multi-threaded fast-path disabling.

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

                                      SC atomic store hook: save the active thread's clock at its own coordinate.

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

                                        SC atomic load hook: remember the global last-SC-fence clock in this thread.

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

                                          Apply the exact GlobalState fence ordering: acquire fence, SeqCst global RMW-style join, last-SC-write metadata, then release fence. If the source's multi-threaded flag is false, maybe_perform_sync_operation is a no-op.

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