-
Notifications
You must be signed in to change notification settings - Fork 277
associate variables' names to tmp_post #6847
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
associate variables' names to tmp_post #6847
Conversation
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.
Would it be possible to please add a test? Such a test would probably go in the regression/goto-cc-cbmc/
and would either use a pattern checking for the expected name in the counterexample trace or could use --show-goto-functions
.
Codecov Report
@@ Coverage Diff @@
## develop #6847 +/- ##
===========================================
+ Coverage 77.78% 78.00% +0.21%
===========================================
Files 1567 1567
Lines 179769 187228 +7459
===========================================
+ Hits 139840 146039 +6199
- Misses 39929 41189 +1260
Continue to review full report at Codecov.
|
std::string suffix = "post"; | ||
if(auto sym_expr = expr_try_dynamic_cast<symbol_exprt>(tmp)) | ||
{ | ||
const irep_idt &base_name = ns.lookup(sym_expr->get_identifier()).base_name; |
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.
Clang-format:
- const irep_idt &base_name = ns.lookup(sym_expr->get_identifier()).base_name;
+ const irep_idt &base_name =
+ ns.lookup(sym_expr->get_identifier()).base_name;
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.
Thanks. I applied the fix.
8a3244f
to
18f65f5
Compare
I added a test that match the name of the checked variable against |
fe258c1
to
5819620
Compare
I like this idea, but I think we should generalize this beyond just symbols to be more useful. Would it be possible to keep these tmp_post variables around as they are, but in the assertion that's printed show the precise subexpression that violated the assertion? EDIT: Sorry! I was typing on my phone and accidentally hit "Close PR" :| |
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.
Please not that there appears to be stray whitespace at the end of lines. https://github.com/diffblue/cbmc/runs/6400807830?check_suite_focus=true says which ones, but arguably the cppcheck report is a bit more useful on this occasion as whitespace changes are difficult to understand in unified diff output...
A challenge here is that the assertions are only generated after the transformations touched in this PR, so the code generating assertions does not even have access to the original expression anymore. Now it may well be possible to work around that in the following way (but this is just a sketch of an idea, I haven't tried this): For any introduced temporary symbol, set the |
Thanks @tautschnig.
Would be great if the
|
Good idea! I will draft another PR to realize this approach. |
if(auto sym_expr = expr_try_dynamic_cast<symbol_exprt>(tmp)) | ||
{ | ||
const irep_idt &base_name = | ||
ns.lookup(sym_expr->get_identifier()).base_name; |
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.
Please change to ns.lookup(*sym_expr)
for stronger typing!
I created a new PR#6855 which I think is a better approach for this problem. |
Re-opening as #6855 needs a lot more testing (and perhaps discussion). @Herbping could you please address the whitespace issues so that this one can be merged? |
5819620
to
b1f440a
Compare
Sounds great @tautschnig. I applied Daniel's comment and addressed the whitespace issue. |
For pointer dereference
(*ptr++)
with side effect, the existing CBMCgoto_convert_side_effect.cpp
creates a temporary variablestmp_post
and later dereferencetmp_post
instead ofptr
. One problem of this approach is that the temporary variabletmp_post
lose all the information about the original pointerptr
. So the trace cannot correctly tell which pointers cause the failure.This patch associate the name of the original variable to the temporary variable, so that the trace will reflect a more precise cause of failure.
Example:
In the above function, if the out-of-boundary check fails on the pointer dereference
(*sc1++)
, the trace will give the violated property asHowever, without looking at the goto program, users will have no clue what is
tmp_post
. With this patch, the violated property will becomewhere the suffix of the temporary variable indicate the cause of the failure.