Skip to content

Include tests from reported issue cbmc#5952. #6212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>

bool validate(const char *data, unsigned allocated)
{
// clang-format off
bool check_1 = (data == NULL ==> allocated == 0);
bool check_2 = (allocated != 0 ==> __CPROVER_r_ok(data, allocated));
// clang-format on
return check_1 && check_2;
}

void main()
{
char *data;
unsigned allocated;

data = (allocated == 0) ? NULL : malloc(allocated);

__CPROVER_assume(validate(data, allocated));

assert(validate(data, allocated));
}
9 changes: 9 additions & 0 deletions regression/cbmc/issue_5952_soundness_bug_smt_encoding/short.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <assert.h>
#include <stdlib.h>

void main()
{
char *data;
data = nondet() ? malloc(1) : malloc(2);
assert(__CPROVER_OBJECT_SIZE(data) <= 2);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
KNOWNBUG broken-smt-backend
original_repro.c
--smt2
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
\[main.assertion.\d\] line \d+ assertion validate\(data, allocated\): SUCCESS
--
\[main.assertion.\d\] line \d+ assertion validate\(data, allocated\): FAILURE
--
This is the original code that demonstrates the issue described in
https://github.com/diffblue/cbmc/issues/5952
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
short.c
--smt2
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
\[main.assertion.\d\] line \d assertion __CPROVER_OBJECT_SIZE\(data\) <= 2: SUCCESS
--
\[main.assertion.\d\] line \d assertion __CPROVER_OBJECT_SIZE\(data\) <= 2: FAILURE
--
This is the reduced version of the issue described in
https://github.com/diffblue/cbmc/issues/5952