Documentation

Miri.Concurrency.Thread

Thread lifecycle state used by Miri's concurrency hooks #

This is a source-shaped state model of src/concurrency/thread.rs at the pinned revision. It keeps the manager's contiguous, never-reused thread IDs, active ID, every thread's Enabled/Blocked/Terminated state, join status, blocked callback token and deadline, names, stacks, origin span, stack-empty callback, frame-cache index, unwind payloads, last-error location, TLS map, and scheduler flags. Interpreter frames, pointers, spans, and machine callbacks are opaque tokens here: their concrete Miri behavior is outside Lean's concurrency state model, and callback-dependent operations return explicit obligations rather than assuming callback success.

This module does not implement MIR execution, TLS allocation/deallocation, stack unwinding, callback code, or Miri's scheduler.

A Rust ThreadId, represented with the exact unsigned 32-bit bound.

  • value : Fin 4294967296
Instances For
    Equations
    Instances For
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def Miri.Concurrency.ThreadId.ofU32 (value : Nat) (bound : value < 4294967296) :
        Equations
        Instances For

          Checked counterpart of rustc-index Idx::new for host vector indices.

          Equations
          Instances For

            Reasons retained verbatim by ThreadState::Blocked.

            Instances For
              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

                  Deadline kind and opaque clock value. Clock arithmetic is owned by Miri's clock subsystem and is not silently approximated here.

                  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
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            Callback-free view of the thread state tag and blocked payload.

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

                                Opaque per-thread interpreter fields, preserved by lifecycle updates. Each field corresponds to an actual Thread field in pinned Miri.

                                Instances For
                                  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
                                        Equations
                                        Instances For

                                          Thread-local allocation identity; the pointer token is preserved but not interpreted as a Rust pointer by this module.

                                          Instances For
                                            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
                                                Instances For
                                                  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

                                                      Miri's EvalContext::block_thread restrictions, checked before mutating the ThreadManager. These are source panics/unsupported configurations, not UB or successful blocking outcomes.

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

                                                          Checked counterpart of rustc-index Idx::new for host vector indices.

                                                          Equations
                                                          Instances For

                                                            A callback obligation created by unblockThread. It records the exact callback token and execution context. A caller must supply the actual callback execution result and resulting machine state; this model does not assume it returns normally.

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

                                                                Outcome that the caller obtained by actually invoking the thread's on_stack_empty callback.

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

                                                                    A source TLS allocation that must be deallocated or retained as an exit static root before the vector-clock termination hook runs.

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

                                                                        Ordered work emitted when Miri marks a thread terminated. TLS cleanup and the data-race termination hook precede waking joiners in the original source.

                                                                        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
                                                                                Instances For
                                                                                  Equations
                                                                                  • One or more equations did not get rendered due to their size.
                                                                                  Instances For

                                                                                    ThreadManager state from pinned Miri, with opaque TLS pointers and callback tokens retained as data. Threads remain in the list after termination.

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

                                                                                        The continuation after successful TLS work. dataRaceHookThread must be passed to GlobalState.threadTerminated before joinWaiters are unblocked.

                                                                                        Instances For
                                                                                          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

                                                                                              Miri's post-construction initialization: install the main stack callback; on non-Windows targets the main thread is detached.

                                                                                              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
                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                  Instances For

                                                                                                    create_thread allocates the next never-reused ID and an enabled, joinable thread whose stack-empty callback is retained.

                                                                                                    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

                                                                                                        Detach follows the two source branches, including Windows' allowance for detaching an already-terminated joined thread exactly once.

                                                                                                        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
                                                                                                            • 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

                                                                                                                Put a blocked thread back in Enabled state and switch to it for execution. The callback is returned as an obligation, not executed or assumed successful.

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

                                                                                                                  Successful callback return restores the previous active thread while preserving every state change made by the supplied callback execution.

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

                                                                                                                    The callback's exceptional return preserves its post-call machine state; the source's ? returns before restoring the old active thread.

                                                                                                                    Equations
                                                                                                                    Instances For

                                                                                                                      set_active_thread accepts any existing ID, including blocked or terminated IDs; callers own source-level scheduling conditions.

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

                                                                                                                        Begin Miri's termination path after the stack-empty callback has returned Poll::Ready. The state is marked Terminated first and TLS entries are removed from the manager exactly as the source's retain does; cleanup itself remains an explicit ordered obligation.

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

                                                                                                                          Continue only when the external interpreter reports exactly the source TLS action for each pointer. A failed deallocation stops before the data-race termination hook and before joiner callbacks, as in Miri's ? propagation.

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