-
Notifications
You must be signed in to change notification settings - Fork 273
Instrument strchr to use the string refinement solver #5200
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
base: develop
Are you sure you want to change the base?
Changes from all commits
941eed4
8d82639
3f76f13
80c88cc
ddf72d1
0879ad0
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,15 @@ | ||
#include <assert.h> | ||
#include <string.h> | ||
|
||
int main() | ||
{ | ||
char test[] = "foo"; | ||
|
||
char *first_o = strchr(test, 'o'); | ||
assert(*first_o == test[1]); | ||
assert(*first_o == test[0]); | ||
char *first_t = strchr(test, 't'); | ||
assert(*first_t == test[1]); | ||
assert(*first_t == test[0]); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CORE broken-smt-backend | ||
test.c | ||
--refine-strings --max-nondet-string-length 10 | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^\[main.assertion.\d+\] line \d+ assertion \*first_o == test\[1\]: SUCCESS$ | ||
^\[main.assertion.\d+\] line \d+ assertion \*first_o == test\[0\]: FAILURE$ | ||
^\[main.assertion.\d+\] line \d+ assertion \*first_t == test\[1\]: FAILURE$ | ||
^\[main.assertion.\d+\] line \d+ assertion \*first_t == test\[0\]: FAILURE$ | ||
^VERIFICATION FAILED$ | ||
-- | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <assert.h> | ||
#include <string.h> | ||
|
||
int main() | ||
{ | ||
int i; | ||
char *test = i ? "fo\0tis" : "notfoti"; | ||
|
||
char *first_o = strchr(test, 'o'); | ||
assert(first_o != NULL); | ||
assert(*first_o == test[0]); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CORE broken-smt-backend | ||
test.c | ||
--refine-strings | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^\[main.assertion.\d+\] line \d+ assertion first_o != (NULL|\(\(void \*\)0\)): SUCCESS$ | ||
^\[main.assertion.\d+\] line \d+ assertion \*first_o == test\[0\]: FAILURE$ | ||
^VERIFICATION FAILED$ | ||
-- | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -362,6 +362,9 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options) | |
{ | ||
options.set_option("refine-strings", true); | ||
options.set_option("string-printable", cmdline.isset("string-printable")); | ||
options.set_option( | ||
"max-nondet-string-length", | ||
cmdline.get_value("max-nondet-string-length")); | ||
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. Does this need a default value as is in jbmc? 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. Also note jbmc throws an error if you use this option without |
||
} | ||
|
||
if(cmdline.isset("max-node-refinement")) | ||
|
@@ -830,8 +833,13 @@ bool cbmc_parse_optionst::process_goto_program( | |
link_to_library( | ||
goto_model, log.get_message_handler(), cprover_c_library_factory); | ||
|
||
if(options.get_bool_option("string-abstraction")) | ||
string_instrumentation(goto_model, log.get_message_handler()); | ||
if( | ||
options.get_bool_option("string-abstraction") || | ||
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. Maybe I am getting mixed up but I thought the "string-abstraction" options did something very different? Maybe that was in goto-instrument. |
||
options.get_bool_option("refine-strings")) | ||
string_instrumentation( | ||
goto_model, | ||
log.get_message_handler(), | ||
options.get_option("max-nondet-string-length")); | ||
|
||
// remove function pointers | ||
log.status() << "Removal of function pointers and virtual functions" | ||
|
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.
There should be a test for the case when a character can’t be found as well, e.g. in this case
't'
may or may not be found depending oni
.