-
Notifications
You must be signed in to change notification settings - Fork 276
Memory snapshot harness havoc #4351
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
int x = 1; | ||
|
||
int main() | ||
{ | ||
assert(x == 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what exactly is this test testing? Presumably this assertion would still fail if the snapshot harness didn't work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified. |
||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-location main:0 --havoc-variables x | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
\[main.assertion.1\] line [0-9]+ assertion x == 1: FAILURE | ||
-- | ||
^warning: ignoring | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be helpful to document how the JSON snapshots were generated. There will be a day where we need to change them in some way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That documentation was intended to be a part of #4261 (as we used the memory-analyzer to generate the JSON). Do you think it should be documented here as well? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <assert.h> | ||
|
||
unsigned int x; | ||
unsigned int y; | ||
|
||
unsigned int nondet_int() | ||
{ | ||
unsigned int z; | ||
return z; | ||
} | ||
|
||
void checkpoint() | ||
{ | ||
} | ||
|
||
unsigned int complex_function_which_returns_one() | ||
{ | ||
unsigned int i = 0; | ||
while(++i < 1000001) | ||
{ | ||
if(nondet_int() && ((i & 1) == 1)) | ||
break; | ||
} | ||
return i & 1; | ||
} | ||
|
||
void fill_array(unsigned int *arr, unsigned int size) | ||
{ | ||
for(unsigned int i = 0; i < size; i++) | ||
arr[i] = nondet_int(); | ||
} | ||
|
||
unsigned int array_sum(unsigned int *arr, unsigned int size) | ||
{ | ||
unsigned int sum = 0; | ||
for(unsigned int i = 0; i < size; i++) | ||
sum += arr[i]; | ||
return sum; | ||
} | ||
|
||
const unsigned int array_size = 100000; | ||
|
||
int main() | ||
{ | ||
x = complex_function_which_returns_one(); | ||
unsigned int large_array[array_size]; | ||
fill_array(large_array, array_size); | ||
y = array_sum(large_array, array_size); | ||
checkpoint(); | ||
assert(y + 2 > y); //y is nondet -- may overflow | ||
assert(0); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
main.c | ||
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-y-snapshot.json --initial-location main:9 --havoc-variables y | ||
^\[main.assertion.1\] line \d+ assertion y \+ 2 > y: FAILURE$ | ||
^\[main.assertion.2\] line \d+ assertion 0: FAILURE$ | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <assert.h> | ||
|
||
struct simple_str | ||
{ | ||
int i; | ||
int j; | ||
} simple; | ||
|
||
void checkpoint() | ||
{ | ||
} | ||
|
||
int main() | ||
{ | ||
simple.i = 1; | ||
simple.j = 2; | ||
|
||
checkpoint(); | ||
assert(simple.j > simple.i); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-struct-snapshot.json --initial-location main:3 --havoc-variables simple | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^\[main.assertion.1\] line \d+ assertion simple.j > simple.i: FAILURE$ | ||
-- | ||
^warning: ignoring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any documentation for the
memory-analyzer
? I recall seeing some around, but I can't seem to be able to find it now? If we don't, would it be a good idea to write some separate documentation for that as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xbauch#3 I intent to make it part of #4261 once review-able.