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
Kani encodes string slices as null-terminated C slices #1665
The pointer is 1-passed the bound of the object, so it is "weak_valid", in the sense defined by CompCert, meaning that it is either in-bound or one-passed-the bound of the object. According to C standard, that is not undefined behaviour, and shouldn't be detected as such. However, it seems that, in addition to check that the pointer can be created, this test also checks that it can be dereferenced which is always UB.
@danielsn mentioned it might be on purpose because the stdlib does that sometimes, but I haven't been able to find an example
This is due to the fact that Kani encodes rust str constants into string constants for CBMC
However, CBMC automatically null-terminates C strings, and therefore, this is indeed not out-of-bound access for CBMC which is why it's not detected.
The solution might be to just have CBMC make non-null terminated constants
Activity
zhassan-aws commentedon Sep 12, 2022
Interestingly, Kani reports the dereference failure if I change it to an array:
[-]Kani is not detecting out-of-bounds dereferencing[/-][+]Kani encodes string slices as null-terminated C slices[/+]giltho commentedon Sep 12, 2022
This is due to the fact that Kani encodes rust str constants into string constants for CBMC
However, CBMC automatically null-terminates C strings, and therefore, this is indeed not out-of-bound access for CBMC which is why it's not detected.
The solution might be to just have CBMC make non-null terminated constants