-
Notifications
You must be signed in to change notification settings - Fork 273
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
Permit re-setting --object-bits #7858
Changes from all commits
944c151
428375a
fb578a6
97e2439
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CORE winbug | ||
CORE | ||
test.c | ||
--function main --object-bits 6 | ||
^EXIT=10$ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CORE winbug | ||
CORE | ||
test.c | ||
--function main --object-bits 10 | ||
^EXIT=10$ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,11 @@ extern const void *__CPROVER_deallocated; | |
extern const void *__CPROVER_memory_leak; | ||
|
||
extern int __CPROVER_malloc_failure_mode; | ||
extern __CPROVER_size_t __CPROVER_max_malloc_size; | ||
extern __CPROVER_bool __CPROVER_malloc_may_fail; | ||
// The maximum size of an object that we can handle under the object:offset | ||
// pointer encoding. Marked thread-local as it is a per-analysis constant that | ||
// can safely be constant-propagated even in concurrent execution. | ||
extern __CPROVER_thread_local __CPROVER_size_t __CPROVER_max_malloc_size; | ||
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. Why is this thread local? 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 to avoid our concurrency encoding picking the variable as one that can't be constant-propagated. 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 have now added a comment to clarify this. 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. Would making it 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. We don't commonly trust |
||
|
||
// malloc failure modes | ||
extern int __CPROVER_malloc_failure_mode_return_null; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,16 +77,17 @@ | |
/// assigned to nondet-initializable static variables with nondeterministic | ||
/// values. | ||
/// \param ns: Namespace for resolving type information. | ||
/// \param [out] goto_functions: Existing goto-functions to be updated. | ||
/// \param [inout] goto_model: Existing goto-functions and symbol table to | ||
/// be updated. | ||
/// \param fct_name: Name of the goto-function to be updated. | ||
static void nondet_static( | ||
const namespacet &ns, | ||
goto_functionst &goto_functions, | ||
goto_modelt &goto_model, | ||
const irep_idt &fct_name) | ||
{ | ||
goto_functionst::function_mapt::iterator fct_entry = | ||
goto_functions.function_map.find(fct_name); | ||
CHECK_RETURN(fct_entry != goto_functions.function_map.end()); | ||
goto_model.goto_functions.function_map.find(fct_name); | ||
CHECK_RETURN(fct_entry != goto_model.goto_functions.function_map.end()); | ||
|
||
goto_programt &init = fct_entry->second.body; | ||
|
||
|
@@ -99,11 +100,11 @@ | |
|
||
if(is_nondet_initializable_static(sym, ns)) | ||
{ | ||
const auto source_location = instruction.source_location(); | ||
instruction = goto_programt::make_assignment( | ||
code_assignt( | ||
sym, side_effect_expr_nondett(sym.type(), source_location)), | ||
source_location); | ||
side_effect_expr_nondett nondet{ | ||
sym.type(), instruction.source_location()}; | ||
instruction.assign_rhs_nonconst() = nondet; | ||
goto_model.symbol_table.get_writeable_ref(sym.get_identifier()).value = | ||
nondet; | ||
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 line here seems to be the cause of the failure in the incremental SMT2 decision procedure. The failure happens during the conversion of the
This isn't supported by the decision procedure. I think the expressions sent to it either directly or from looking up the values of symbols are expected to be side effect free. The only exception would be in the case where we take the address of a code typed expression. The example in this test does not fall into this exception, because It could be argued that the decision procedure should not error in this case. However I would say that this change in the value of symbols unrelated to max_malloc_size / object bits appears to be a change unrelated to the intended purpose of this PR. 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 need to figure out why the value in the symbol table is used directly. What should happen is that such a value is compiled into an assignment in 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. The problem appears to have been introduced in f286c07: @thomasspriggs, why is it deemed necessary to lookup a symbol's value in 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. Because the API for I can raise a PR which changes this such that symbol expressions are implicitly defined to have a nondeterministic value instead, if that is how a decision procedure should be implemented. |
||
} | ||
} | ||
else if(instruction.is_function_call()) | ||
|
@@ -113,33 +114,24 @@ | |
// see cpp/cpp_typecheck.cpp, which creates initialization functions | ||
if(fsym.get_identifier().starts_with("#cpp_dynamic_initialization#")) | ||
{ | ||
nondet_static(ns, goto_functions, fsym.get_identifier()); | ||
nondet_static(ns, goto_model, fsym.get_identifier()); | ||
} | ||
} | ||
} | ||
|
||
// update counters etc. | ||
goto_functions.update(); | ||
} | ||
|
||
/// Nondeterministically initializes global scope variables in | ||
/// CPROVER_initialize function. | ||
/// \param ns: Namespace for resolving type information. | ||
/// \param [out] goto_functions: Existing goto-functions to be updated. | ||
void nondet_static(const namespacet &ns, goto_functionst &goto_functions) | ||
{ | ||
nondet_static(ns, goto_functions, INITIALIZE_FUNCTION); | ||
goto_model.goto_functions.update(); | ||
} | ||
|
||
/// First main entry point of the module. Nondeterministically initializes | ||
/// global scope variables, except for constants (such as string literals, final | ||
/// fields) and internal variables (such as CPROVER and symex variables, | ||
/// language specific internal variables). | ||
/// \param [out] goto_model: Existing goto-model to be updated. | ||
/// \param [inout] goto_model: Existing goto-model to be updated. | ||
void nondet_static(goto_modelt &goto_model) | ||
{ | ||
const namespacet ns(goto_model.symbol_table); | ||
nondet_static(ns, goto_model.goto_functions); | ||
nondet_static(ns, goto_model, INITIALIZE_FUNCTION); | ||
} | ||
|
||
/// Second main entry point of the module. Nondeterministically initializes | ||
|
@@ -199,7 +191,7 @@ | |
} | ||
} | ||
|
||
nondet_static(ns, goto_model.goto_functions, INITIALIZE_FUNCTION); | ||
nondet_static(ns, goto_model, INITIALIZE_FUNCTION); | ||
} | ||
|
||
/// Nondeterministically initializes global scope variables that | ||
|
@@ -227,5 +219,5 @@ | |
} | ||
|
||
const namespacet ns(goto_model.symbol_table); | ||
nondet_static(ns, goto_model.goto_functions, INITIALIZE_FUNCTION); | ||
nondet_static(ns, goto_model, INITIALIZE_FUNCTION); | ||
} |
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.
❓ Where is this warning produced in this PR? Or does that already exist?
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.
goto-cc warns about all options that it doesn't explicitly know about, so by virtue of removing it from
gcc_cmdline.cpp
we get this.