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
-Z valid-value-checks only instruments the first check in each basic block #5194
-Z valid-value-checks instruments only the first check in each basic block. A second invalid read in the same block isn't checked, so the harness verifies:
#[kani::proof]fnsecond_read_invalid(){let good:u8 = 1;let bad:u8 = 2;let p = &good as*constu8as*constbool;let q = &bad as*constu8as*constbool;let _a = unsafe{*p };let _b = unsafe{*q };// UB: 2 is not a valid bool}
With the two reads swapped, the invalid one comes first and is reported. With debug assertions on, rustc's alignment check for each raw-pointer read splits the block, which hides the bug in this example; it doesn't for writes, field accesses or reads through references.
Cause.ValidValuePass::transform (kani-compiler/src/kani_middle/transform/check_values.rs) loops with for bb_idx in 0..new_body.blocks().len(). The comment above it says the length must not be cached, but the range is evaluated once. Inserting a check splits the block and moves the instructions after it to a new block at the end, which the loop never visits.
Fix. Loop with while bb_idx < new_body.blocks().len(). It's on branch valid-value-untyped-writes (PR to come, together with #3762, #5190 and #5021, which depend on it), with a regression test (tests/expected/valid-value-checks/untyped_store.rs, a write and a later read in one block).
Activity
Valid-value checks: check reads of untyped bytes, not untyped writes (m…