You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Quantifier predicates that read restricted types through captured references are rejected under -Z valid-value-checks #5193
With -Z valid-value-checks, a quantifier predicate that reads a value of a restricted type (bool, char, a function pointer, ...) through a captured reference is rejected:
error: quantifier predicates containing safety checks are not supported with -Z valid-value-checks or -Z uninit-checks
Why it happens. The fix for #3762 and #5190 (branch valid-value-untyped-writes, PR to come) stops checking untyped writes (write_bytes, copies, stores through a pointer to an unrestricted type) and checks the typed reads of those bytes instead, as the language specifies. A read through a pointer may read bytes written that way, so it gets a check. Quantifier predicates can't contain checks, so Kani rejects them. Before that change, these reads were never checked, which missed UB such as an invalid char copied in with ptr::copy and read back.
What still works. Values the closure captures by value or by move aren't checked, since a closure's environment is built by a typed aggregate. Reads of integers and other types without validity requirements aren't checked either.
What this blocks. Quantifiers over captured slices or arrays of restricted types under -Z valid-value-checks, which is the common way to state a property of every element.
Tests on that branch:
tests/ui/quantifier-safety-checks/captured_reference.rs records the rejection.
tests/ui/quantifier-safety-checks/indirect_call.rs now captures its function pointer by move, so it still reaches the "indirect function call" error it tests.
Possible directions:
Hoist the check out of the predicate: before the quantifier, check that the memory the predicate reads has no untyped bytes. For a slice, that's a check over its range; the check itself can then be expressed with a quantifier.
Leave predicates unchecked, and check the captured memory where the closure is created.
Support the check inside the quantifier encoding, if CBMC's quantifier support allows a guarded validity test there.
Option 1 keeps the reads sound and seems the most direct. Input welcome on which fits the quantifier encoding best.
Activity
Valid-value checks: check reads of untyped bytes, not untyped writes (m…