Skip to content

Discrepancy between API specification and behavior for __CPROVER_r_ok #8199

Open
@celinval

Description

@celinval

CBMC version: 5.95.1
Operating system: Ubuntu 22.04
Exact command line resulting in the issue: cbmc main.c
What behaviour did you expect: I expected the specification to say that the __CPROVER_r_ok returns non-deterministic value for non-null invalid pointers.
What happened instead: The specification explicitly says that calling __CPROVER_r_ok with invalid pointer has undefined behavior. Hence, I can only conclude that the assert(__CPROVER_r_ok()) will fail if the pointer is null.

I.e.: According to the specification, the following implementation would be perfectly fine:

int __CPROVER_r_ok(void* ptr, int sz) {
    return ptr != 0;
}

Which would make the following snippet unsound unless if user invokes it with --pointer-primitive-check:

int* function() {
    int* ptr;
    assume(ptr != NULL);
    assert(__CPROVER_r_ok(ptr, 1));
    return ptr;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    KaniBugs or features of importance to Kani Rust Verifierpending merge

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions