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
Support references in "modifies" (or "assigns") clause of function contracts. #1546
Requested feature:
The modifies clause in Kani function contracts only supports variables right now. For example, we can specify something like #[kani::modifies(a)] where a:i32. The modifies clause specifies the write-set (or the memory footprint) of the function. We need to extend this to support references inside the modifies clause.
Potential issues while implementing this feature -
Every function contract has a #[kani::proof] attribute attached to it. Hence, in the above example, while checking if the function incr satisfies its contract, Kani will complain about a potential null pointer dereferencing error. This occurs because Kani non-dets the function arguments (Hence, x could be a null pointer) and then tries to deference x within the body. To get around this, we need to automatically inject an assume statement that kani::assume(write_ok(x)) where write_ok would behave like CBMC's __CPROVER_w_ok memory predicate. That is, assume that the pointer has some memory allocated. We need can automatically inject this assumption for any mutable reference in the list of function arguments.
Handling * character in Rust AST after macro expansion.
The #[kani::modifies(*x)] gets rewritted to #[kanitool::modifies(*x)] during macro expansion. #[kanitool::modifies(*x)] attribute is then handled during codegen. The information is now at the Rust MIR level. When I tried implementing this feature, I ran into an issue in the Rust MIR level. Specifically, it is represented as a Rust AST MetaItem whose type only represents words (E.g. #[test]), name value pairs (E.g. #[feature = "foo"]), or a list of nested meta items (E.g. #[derive(..)]). I'm not sure if it will be able to represent the "*" token. A solution might be to include the modifies set in the function body during macro expansion and to pass it to CBMC from there (by creating a new symbol for the function contract).
Activity