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.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Instances For
Reasons retained verbatim by ThreadState::Blocked.
- Join (thread : ThreadId) : BlockReason
- Sleep : BlockReason
- Mutex : BlockReason
- Condvar : BlockReason
- RwLock : BlockReason
- Semaphore : BlockReason
- Futex : BlockReason
- InitOnce : BlockReason
- Readiness : BlockReason
- Eventfd : BlockReason
- VirtualSocket : BlockReason
- IO : BlockReason
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
Deadline kind and opaque clock value. Clock arithmetic is owned by Miri's clock subsystem and is not silently approximated here.
- Monotonic (opaqueInstant : Nat) : ThreadDeadline
- RealTime (opaqueSystemTime : Nat) : ThreadDeadline
Instances For
Equations
- Miri.Concurrency.instDecidableEqThreadDeadline.decEq (Miri.Concurrency.ThreadDeadline.Monotonic a) (Miri.Concurrency.ThreadDeadline.Monotonic b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Miri.Concurrency.instDecidableEqThreadDeadline.decEq (Miri.Concurrency.ThreadDeadline.Monotonic opaqueInstant) (Miri.Concurrency.ThreadDeadline.RealTime opaqueSystemTime) = isFalse ⋯
- Miri.Concurrency.instDecidableEqThreadDeadline.decEq (Miri.Concurrency.ThreadDeadline.RealTime opaqueSystemTime) (Miri.Concurrency.ThreadDeadline.Monotonic opaqueInstant) = isFalse ⋯
- Miri.Concurrency.instDecidableEqThreadDeadline.decEq (Miri.Concurrency.ThreadDeadline.RealTime a) (Miri.Concurrency.ThreadDeadline.RealTime b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
- Ready : UnblockKind
- TimedOut : UnblockKind
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Joinable : ThreadJoinStatus
- Detached : ThreadJoinStatus
- Joined : ThreadJoinStatus
Instances For
Equations
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.
- Enabled : ThreadState
- Blocked (reason : BlockReason) (deadline : Option ThreadDeadline) (callbackToken : Nat) : ThreadState
- Terminated : ThreadState
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Miri.Concurrency.instDecidableEqThreadState.decEq Miri.Concurrency.ThreadState.Enabled Miri.Concurrency.ThreadState.Enabled = isTrue ⋯
- Miri.Concurrency.instDecidableEqThreadState.decEq Miri.Concurrency.ThreadState.Enabled (Miri.Concurrency.ThreadState.Blocked reason deadline callbackToken) = isFalse ⋯
- Miri.Concurrency.instDecidableEqThreadState.decEq (Miri.Concurrency.ThreadState.Blocked reason deadline callbackToken) Miri.Concurrency.ThreadState.Enabled = isFalse ⋯
- Miri.Concurrency.instDecidableEqThreadState.decEq (Miri.Concurrency.ThreadState.Blocked reason deadline callbackToken) Miri.Concurrency.ThreadState.Terminated = isFalse ⋯
- Miri.Concurrency.instDecidableEqThreadState.decEq Miri.Concurrency.ThreadState.Terminated (Miri.Concurrency.ThreadState.Blocked reason deadline callbackToken) = isFalse ⋯
- Miri.Concurrency.instDecidableEqThreadState.decEq Miri.Concurrency.ThreadState.Terminated Miri.Concurrency.ThreadState.Terminated = isTrue ⋯
Instances For
Equations
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.
- state : ThreadState
- originSpanToken : Nat
- joinStatus : ThreadJoinStatus
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- thread.isTerminated = match thread.state with | Miri.Concurrency.ThreadState.Terminated => true | x => false
Instances For
Equations
- thread.isBlockedOn reason = match thread.state with | Miri.Concurrency.ThreadState.Blocked actual deadline callbackToken => actual == reason | x => false
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
- threadIdOverflow : ThreadError
- invalidId : ThreadError
- terminated (thread : ThreadId) : ThreadError
- activeIdOutOfBounds (thread : ThreadId) : ThreadError
- activeThreadNotEnabled (thread : ThreadId) : ThreadError
- stackEmptyCallbackPending (thread : ThreadId) : ThreadError
- stackNotEmptyAtTermination (thread : ThreadId) : ThreadError
- targetNotBlocked (thread : ThreadId) : ThreadError
- wrongBlockReason (expected actual : BlockReason) : ThreadError
- detachAlreadyConsumed (thread : ThreadId) : ThreadError
- detachNotJoinable (thread : ThreadId) : ThreadError
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
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.
- realTimeTimeoutInIsolation : BlockThreadSourceError
- thread (error : ThreadError) : BlockThreadSourceError
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
- Miri.Concurrency.ThreadId.ofNat value = if bound : value < 4294967296 then Except.ok { value := ⟨value, bound⟩ } else Except.error Miri.Concurrency.ThreadError.threadIdOverflow
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.
- target : ThreadId
- previousActive : ThreadId
- reason : BlockReason
- callbackToken : Nat
- kind : UnblockKind
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.
- Ready : StackEmptyCallbackResult
- Pending : StackEmptyCallbackResult
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
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.
- thread : ThreadId
- tlsCleanup : List TlsCleanupObligation
- forExit : Bool
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
- Deallocated (pointerToken : Nat) : TlsCleanupResult
- RetainedAsStaticRoot (pointerToken : Nat) : TlsCleanupResult
- Failed (pointerToken : Nat) : TlsCleanupResult
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Miri.Concurrency.instDecidableEqTlsCleanupResult.decEq (Miri.Concurrency.TlsCleanupResult.Deallocated pointerToken) (Miri.Concurrency.TlsCleanupResult.Failed pointerToken_1) = isFalse ⋯
- Miri.Concurrency.instDecidableEqTlsCleanupResult.decEq (Miri.Concurrency.TlsCleanupResult.Failed pointerToken) (Miri.Concurrency.TlsCleanupResult.Deallocated pointerToken_1) = isFalse ⋯
- Miri.Concurrency.instDecidableEqTlsCleanupResult.decEq (Miri.Concurrency.TlsCleanupResult.Failed a) (Miri.Concurrency.TlsCleanupResult.Failed b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- threadError (error : ThreadError) : ThreadTerminationError
- callbackFailedOrIncomplete : ThreadTerminationError
- cleanupResultCountMismatch : ThreadTerminationError
- cleanupResultMismatch (expected actual : TlsCleanupResult) : ThreadTerminationError
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.
- activeThread : ThreadId
- threads : List ThreadRecord
- threadLocalAllocs : List ThreadLocalAllocation
- yieldActiveThread : Bool
- fixedScheduling : Bool
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
The continuation after successful TLS work. dataRaceHookThread must be
passed to GlobalState.threadTerminated before joinWaiters are unblocked.
- manager : ThreadManager
- dataRaceHookThread : ThreadId
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
- manager.totalThreadCount = manager.threads.length
Instances For
Equations
- manager.liveThreadCount = List.countP (fun (thread : Miri.Concurrency.ThreadRecord) => !thread.isTerminated) manager.threads
Instances For
Equations
- manager.activeThread? = Miri.Concurrency.ThreadManager.get?✝ manager.threads manager.activeThread.toNat
Instances For
Equations
- manager.thread? id = Miri.Concurrency.ThreadManager.get?✝ manager.threads id.toNat
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
- managerAfterFailure.callbackFailedState _obligation = managerAfterFailure
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.