Documentation

Miri.Memory.Validity

The scalar and primitive validity core from pinned rustc_const_eval::interpret::validity. It preserves the source distinction between invalid integer bits, a possibly-null relative pointer, and a pointer whose absolute address is unknown. Allocation reads and pointer/null checks remain explicit inputs; aggregate and metadata validation return delegation steps rather than being treated as successful values.

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
          @[instance_reducible]
          Equations
          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
                    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
                            Equations
                            Instances For
                              def Miri.Memory.ValidationPath.withElem {α : Type} (path : ValidationPath) (projection : PathElem) (visit : ValidationPath → α) :
                              α
                              Equations
                              Instances For

                                Render projections with the same spelling and order as validity.rs's write_path; originalType is kept separately, as in the source Path.

                                Equations
                                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
                                          Instances For
                                            Equations
                                            Instances For
                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                Instances For
                                                  Equations
                                                  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
                                                            inductive Miri.Memory.ValidityError (MachineError : Type) :
                                                            Instances For
                                                              def Miri.Memory.instDecidableEqValidityError.decEq {MachineError✝ : Type} [DecidableEq MachineError✝] (x✝ x✝¹ : ValidityError MachineError✝) :
                                                              Decidable (x✝ = x✝¹)
                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For
                                                                def Miri.Memory.instReprValidityError.repr {MachineError✝ : Type} [Repr MachineError✝] :
                                                                ValidityError MachineError✝ → Nat → Std.Format
                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  @[instance_reducible]
                                                                  instance Miri.Memory.instReprValidityError {MachineError✝ : Type} [Repr MachineError✝] :
                                                                  Repr (ValidityError MachineError✝)
                                                                  Equations
                                                                  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

                                                                        Non-scalar work is returned to the caller as a required validation step. The caller must supply the matching recursive, metadata, or pointer hooks.

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

                                                                            Sorted, disjoint, non-adjacent set of data-byte ranges used by the source visitor's padding reset. Its constructor is private so malformed interval arrays cannot enter the visitor through this API.

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

                                                                                  Source RangeSet::add_range: zero-sized ranges are ignored; overlapping and adjacent ranges coalesce, preserving sorted disjoint storage.

                                                                                  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

                                                                                          A finite, indexed description of one TyAndLayout node for the pure union_data_range_uncached traversal. Child indices deliberately remain checked at runtime: malformed synthetic layouts cannot be mistaken for an empty union. elementIsScalar is the upstream backend-representation fast-path fact for array elements.

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

                                                                                                    Exact recursive layout walk from ValidityVisitor::union_data_range. The work stack implements its depth-first recursion while detecting malformed cycles and checking each source Size operation.

                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For
                                                                                                      Instances For
                                                                                                        Equations
                                                                                                        Instances For
                                                                                                          Equations
                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                          Instances For
                                                                                                            def Miri.Memory.Validity.checkUnsafeCell {MachineError HookState : Type} (mode : Option CtfeMode) (isZeroSized isUnsafeCell : Bool) (path : ValidationPath) (isMutableMemory : HookState → EStateM.Result (ValidityError MachineError) HookState Bool) :
                                                                                                            EStateM (ValidityError MachineError) HookState Unit

                                                                                                            Source visit_value's UnsafeCell check for the current ADT node. The memory mutability query is required only after CTFE policy, dynamic ZST, and the type predicate establish that it matters.

                                                                                                            Equations
                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                            Instances For
                                                                                                              structure Miri.Memory.Validity.UnionVisitHooks (MachineError HookState : Type) :
                                                                                                              Instances For
                                                                                                                def Miri.Memory.Validity.visitUnion {MachineError HookState : Type} (hooks : UnionVisitHooks MachineError HookState) (mode : Option CtfeMode) (path : ValidationPath) (resetProvenanceAndPadding : Bool) (dataBytes : Option DataRangeSet) (layout : UnionLayoutGraph) :
                                                                                                                EStateM (ValidityError MachineError) HookState (Option DataRangeSet)

                                                                                                                Source ValueVisitor::visit_union: CTFE checks !Freeze before data range collection, and only tracked typed copies query the containing offset. Union layout/range failures remain distinct from validation UB and machine lookup failures.

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

                                                                                                                              Port of aggregate_field_path_elem. Layout and HIR lookup facts are explicit inputs; closure captures fall back to the source's numeric symbol.

                                                                                                                              Equations
                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                              Instances For
                                                                                                                                def Miri.Memory.Validity.visitAggregateField {MachineError HookState α : Type} (path : ValidationPath) (info : AggregatePathInfo) (visit : ValidationPath → EStateM (ValidityError MachineError) HookState α) :
                                                                                                                                EStateM (ValidityError MachineError) HookState α

                                                                                                                                Source visit_field path scoping. The projection lookup is evaluated before the child visitor, and only that child sees the extended path.

                                                                                                                                Equations
                                                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                                                Instances For
                                                                                                                                  def Miri.Memory.Validity.visitAggregateVariant {MachineError HookState α : Type} (path : ValidationPath) (typeName : String) (kind : AggregateTypeKind) (variant : Nat) (name : Option String) (visit : ValidationPath → EStateM (ValidityError MachineError) HookState α) :
                                                                                                                                  EStateM (ValidityError MachineError) HookState α
                                                                                                                                  Equations
                                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                                  Instances For

                                                                                                                                    Compute source reset_padding writes. The final zero-length sentinel closes the last gap; malformed/out-of-object ranges return explicit invariant failures instead of relying on rustc assertions or Size panics.

                                                                                                                                    Equations
                                                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                                                    Instances For
                                                                                                                                      def Miri.Memory.Validity.resetPadding {MachineError HookState : Type} (data : Option DataRangeSet) (allocationRange : HookState → EStateM.Result (ValidityError MachineError) HookState (Option (ABI.Size × ABI.Size))) (writeUninit : AllocRange → HookState → EStateM.Result (ValidityError MachineError) HookState Unit) :
                                                                                                                                      EStateM (ValidityError MachineError) HookState Unit

                                                                                                                                      Execute the planned padding writes in source order. The allocation lookup and byte-mask mutations stay on explicit machine callbacks; a failed write retains all earlier callback state. none data tracking and ZST places are source no-ops.

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

                                                                                                                                                  Machine lookup facts needed by the source CTFE recursion policy. The allocation identity/global query itself belongs to the interpreter callback; the policy decisions are performed here.

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

                                                                                                                                                      Source CTFE-only allocation and mutability checks performed before adding a safe pointer to the recursive worklist. The true result means skip the descent (including the source's delayed-bug/missing-interning early return).

                                                                                                                                                      Equations
                                                                                                                                                      Instances For

                                                                                                                                                        Persistent visitor flags. withMaybeDangling scopes the source's may_dangle |= is_like_maybe_dangling() update and restores the old value on successful return. Errors unwind the visitor just as the source macro does.

                                                                                                                                                        • resetProvenanceAndPadding : Bool
                                                                                                                                                        • mayDangle : Bool
                                                                                                                                                        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
                                                                                                                                                              def Miri.Memory.Validity.withMaybeDangling {Error HookState α : Type} (flags : VisitorFlags) (isLikeMaybeDangling : Bool) (visit : VisitorFlags → EStateM Error HookState α) :
                                                                                                                                                              EStateM Error HookState (α × VisitorFlags)
                                                                                                                                                              Equations
                                                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                                                              Instances For
                                                                                                                                                                structure Miri.Memory.Validity.PrimitiveHooks (Prov MachineError HookState : Type) :

                                                                                                                                                                Mutation and machine-resolution boundary used by ValidityVisitor::try_visit_primitive.

                                                                                                                                                                Instances For

                                                                                                                                                                  Facts returned by the machine's imm_ptr_to_mplace boundary. Dynamic size/alignment and pointer access remain separate callbacks so their ordering matches the pinned visitor.

                                                                                                                                                                  Instances For

                                                                                                                                                                    A small, explicit recursive-reference worklist matching rustc's RefTracking: seen persists after an item is popped, and todo is LIFO.

                                                                                                                                                                    Instances For
                                                                                                                                                                      @[instance_reducible]
                                                                                                                                                                      instance Miri.Memory.Validity.instReprRefTracking {Key✝ Path✝ : Type} [Repr Key✝] [Repr Path✝] :
                                                                                                                                                                      Repr (RefTracking Key✝ Path✝)
                                                                                                                                                                      Equations
                                                                                                                                                                      def Miri.Memory.Validity.instReprRefTracking.repr {Key✝ Path✝ : Type} [Repr Key✝] [Repr Path✝] :
                                                                                                                                                                      RefTracking Key✝ Path✝ → Nat → Std.Format
                                                                                                                                                                      Equations
                                                                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                                                                      Instances For
                                                                                                                                                                        def Miri.Memory.Validity.RefTracking.start {Key Path : Type} (key : Key) (path : Path) :
                                                                                                                                                                        RefTracking Key Path
                                                                                                                                                                        Equations
                                                                                                                                                                        Instances For
                                                                                                                                                                          def Miri.Memory.Validity.RefTracking.next {Key Path : Type} (tracking : RefTracking Key Path) :
                                                                                                                                                                          Option ((Key × Path) × RefTracking Key Path)
                                                                                                                                                                          Equations
                                                                                                                                                                          Instances For
                                                                                                                                                                            def Miri.Memory.Validity.RefTracking.track {Key Path : Type} (tracking : RefTracking Key Path) (key : Key) (makePath : Unit → Path) [DecidableEq Key] :
                                                                                                                                                                            RefTracking Key Path

                                                                                                                                                                            Duplicate references are ignored; makePath is only evaluated on the first visit, matching the source's lazy path construction.

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

                                                                                                                                                                                          Resolved projection facts for the generic ValueVisitor::walk_value engine. The machine/layout adapter supplies child handles in source projection order; each index and field/variant lookup is validated before traversal.

                                                                                                                                                                                          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
                                                                                                                                                                                                  Equations
                                                                                                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                    structure Miri.Memory.Validity.ValueWalkHooks (MachineError HookState : Type) :
                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                      def Miri.Memory.Validity.walkValue {MachineError HookState : Type} (hooks : ValueWalkHooks MachineError HookState) (graph : ValueWalkGraph) (rootPath : ValidationPath) (flags : VisitorFlags) :
                                                                                                                                                                                                      EStateM (ValidityError MachineError) HookState Unit

                                                                                                                                                                                                      Source ValueVisitor::walk_value traversal order, composed with the validity-specific primitive, UnsafeCell, optimized-case, union, and Box hooks. The finite graph contains layout projections supplied by the interpreter; missing projection or machine operations remain explicit failures.

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

                                                                                                                                                                                                        Per-invocation state passed through the source visit_value traversal. The path is a value so child scopes can push a projection and restore it on return; data tracking and recursive-reference discovery are returned by the visitor rather than hidden in a default-success operation.

                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                          structure Miri.Memory.Validity.ValidatePlaceHooks (Place Key MachineError HookState : Type) :
                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                            def Miri.Memory.Validity.validatePlace {Place Key MachineError HookState : Type} [DecidableEq Key] (hooks : ValidatePlaceHooks Place Key MachineError HookState) (root : Place) (originalType : String) (resetProvenanceAndPadding : Bool) (ctfeMode : Option CtfeMode) (initialTracking : Option (RefTracking Key ValidationPath)) (drainTracking : Bool) :
                                                                                                                                                                                                            EStateM (ValidityError MachineError) HookState Unit

                                                                                                                                                                                                            The pinned validate_place_internal orchestration. The actual MIR place projection and recursive type walk are an explicit callback because they depend on rustc's PlaceTy/layout engine; this driver preserves the source setup, mutation order, padding finalizer, and recursive RefTracking drain. Each tracked pointee is visited without provenance reset, with no further tracking, and under may_dangle, as in validate_place.

                                                                                                                                                                                                            Equations
                                                                                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                              structure Miri.Memory.Validity.SafePointerHooks (Prov Key MachineError HookState : Type) :

                                                                                                                                                                                                              Required operations for the source check_safe_pointer path. Each callback stands at a real machine/layout boundary; absent semantics cannot be silently interpreted as success. Callbacks return a ValidityError when the source maps an underlying UB category to a validation failure.

                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                def Miri.Memory.Validity.checkSafePointer {Prov MachineError HookState Key Path : Type} [PointerProvenance Prov] [DecidableEq Key] (hooks : SafePointerHooks Prov Key MachineError HookState) (kind : SafePointerKind) (resetProvenanceAndPadding mayDangle : Bool) (ctfeMode : Option CtfeMode) (targetUsizeMax : UInt64) (tracking : Option (RefTracking Key Path × Path)) (makeDerefPath : Path → Path) (invalidMetadataTail : String → ValidityError MachineError) :
                                                                                                                                                                                                                EStateM (ValidityError MachineError) HookState (Option (RefTracking Key Path))

                                                                                                                                                                                                                Run source-ordered safe-reference/Box validation. The optional tracker, CTFE policy, and reset/may-dangle flags are explicit visitor state. A source machine error or validation failure preserves callback state at the exact failing step. targetUsizeMax is the machine target's maximum address.

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

                                                                                                                                                                                                                  Port of validity.rs::fmt_range, retaining its invariant failures as explicit errors instead of Lean/Rust panics.

                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                      def Miri.Memory.Validity.checkScalar {Prov : Type} [PointerProvenance Prov] {MachineError HookState : Type} (layout : ScalarValidityLayout) (scalar : Scalar Prov) (scalarMayBeNull : Scalar Prov → HookState → EStateM.Result MachineError HookState Bool) :
                                                                                                                                                                                                                      EStateM (ValidityError MachineError) HookState Unit

                                                                                                                                                                                                                      Source ValidityVisitor::visit_scalar, with scalar_may_be_null as a required machine callback. Callback errors pass through unchanged, while the result state is retained on callback failure.

                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                        def Miri.Memory.Validity.checkPrimitive {Prov : Type} [PointerProvenance Prov] {MachineError HookState : Type} (kind : PrimitiveKind) (_layout : ScalarValidityLayout) (scalar : Scalar Prov) (_scalarMayBeNull : Scalar Prov → HookState → EStateM.Result MachineError HookState Bool) :
                                                                                                                                                                                                                        EStateM (ValidityError MachineError) HookState PrimitiveStep

                                                                                                                                                                                                                        Source primitive classification after the memory read. The integer/float case only requires initialized scalar bytes here; valid-range checking is the separate visitScalar operation used by the higher-level visitor when needed. Pointer-specific operations remain explicit delegation steps.

                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                          def Miri.Memory.Validity.visitPrimitive {Prov : Type} [PointerProvenance Prov] {MachineError HookState : Type} (hooks : PrimitiveHooks Prov MachineError HookState) (kind : PrimitiveKind) (layout : ScalarValidityLayout) (scalar : Scalar Prov) (resetProvenanceAndPadding recursiveTracking : Bool) (scalarMayBeNull : Scalar Prov → HookState → EStateM.Result MachineError HookState Bool) :
                                                                                                                                                                                                                          EStateM (ValidityError MachineError) HookState PrimitiveStep

                                                                                                                                                                                                                          Execute the stateful portion of try_visit_primitive. The caller has already read the scalar/immediate at the expected type. This preserves the source order for pointer reset, data-byte tracking, wide-pointer metadata, and function-pointer validation. Safe references and Box delegate to checkSafePointer through distinct explicit steps.

                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                            theorem Miri.Memory.Validity.zero_is_outside_byte_nonzero_niche :
                                                                                                                                                                                                                            { start := 1#128, «end» := 255#128 }.contains 0 = false

                                                                                                                                                                                                                            The standard one-byte nonzero niche excludes the null representation.

                                                                                                                                                                                                                            theorem Miri.Memory.Validity.byte_nonzero_niche_accepts (value : UInt8) (h : (value.toNat != 0) = true) :
                                                                                                                                                                                                                            { start := 1#128, «end» := 255#128 }.contains (BitVec.ofNat 128 value.toNat) = true

                                                                                                                                                                                                                            Any one-byte value from 1 through 255 satisfies the nonzero niche.