-
Notifications
You must be signed in to change notification settings - Fork 273
Havoc non det functions #1585
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
Havoc non det functions #1585
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,9 @@ | ||
void function(int *a); | ||
|
||
int main() | ||
{ | ||
int a=0; | ||
function(&a); | ||
__CPROVER_assert(a==0,""); | ||
return 0; | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CORE | ||
main.c | ||
--havoc-undefined-functions | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
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. Nit: missing empty line |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ class optionst; | |
"(show-symbol-table)(show-parse-tree)(show-vcc)" \ | ||
"(show-claims)(claim):(show-properties)" \ | ||
"(drop-unused-functions)" \ | ||
"(havoc-undefined-functions)" \ | ||
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. This seems like a super useful option in other binaries (such as 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. This is done during symexing rather than by changing the goto-functions, so I can't very easily move this into goto-instrument, but it can be used for any binary that cbmc can analyse. I don't really know what you would expect to be inserted into binaries, if it was to be part of goto-instrument, goto-analyze or goto-cc? It could replace the function body with __CPROVER_havoc(whatever the return values and pointer arguments are), but that is only meaningful if you are going to analyze the binary with cbmc afterwards. |
||
"(property):(stop-on-fail)(trace)" \ | ||
"(error-label):(verbosity):(no-library)" \ | ||
"(nondet-static)" \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <util/c_types.h> | ||
|
||
#include <pointer-analysis/dereference.h> | ||
|
||
#include <analyses/dirty.h> | ||
|
||
bool goto_symext::get_unwind_recursion( | ||
|
@@ -276,6 +278,22 @@ void goto_symext::symex_function_call_code( | |
symex_assign_rec(state, code); | ||
} | ||
|
||
if(options.get_bool_option("havoc-undefined-functions")) | ||
{ | ||
// assign non det to function arguments if pointers | ||
// are not const | ||
for(const auto &arg : call.arguments()) | ||
{ | ||
if(arg.type().id() == ID_pointer && | ||
!arg.type().subtype().get_bool(ID_C_constant)) | ||
{ | ||
exprt object = dereference_exprt(arg, arg.type().subtype()); | ||
clean_expr(object, state, true); | ||
havoc_rec(state, guardt(), object); | ||
} | ||
} | ||
} | ||
|
||
symex_transition(state); | ||
return; | ||
} | ||
|
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.
Nit: missing empty line