Skip to content

CONTRACTS: detect and handle locals in assigns clause checking for loops #6947

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

Merged
merged 1 commit into from
Jun 25, 2022

Conversation

remi-delmas-3000
Copy link
Collaborator

@remi-delmas-3000 remi-delmas-3000 commented Jun 17, 2022

Fixes #6943.

When no assigns clause was provided, we were trying to infer variables touched by the loop and generate an assigns clause from that. Some of these variables could be locals, which have no meaning outside the loop, and we were trying to snapshot these variables outside of the loop. We now detect loop locals and remove them from the inferred frame condition the loop.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • [N/A] My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@remi-delmas-3000 remi-delmas-3000 added bugfix aws Bugs or features of importance to AWS CBMC users aws-high Code Contracts Function and loop contracts labels Jun 17, 2022
@remi-delmas-3000 remi-delmas-3000 self-assigned this Jun 17, 2022
@codecov
Copy link

codecov bot commented Jun 17, 2022

Codecov Report

Merging #6947 (ddd32b4) into develop (baba52b) will increase coverage by 0.03%.
The diff coverage is 89.13%.

❗ Current head ddd32b4 differs from pull request most recent head 00959cc. Consider uploading reports for the commit 00959cc to get more accurate results

@@             Coverage Diff             @@
##           develop    #6947      +/-   ##
===========================================
+ Coverage    77.79%   77.83%   +0.03%     
===========================================
  Files         1568     1569       +1     
  Lines       180347   180350       +3     
===========================================
+ Hits        140309   140370      +61     
+ Misses       40038    39980      -58     
Impacted Files Coverage Δ
...oto-instrument/contracts/instrument_spec_assigns.h 94.73% <ø> (ø)
src/goto-instrument/contracts/utils.h 100.00% <ø> (+16.07%) ⬆️
src/goto-instrument/contracts/cfg_info.h 85.00% <85.00%> (ø)
...o-instrument/contracts/instrument_spec_assigns.cpp 99.35% <95.45%> (+0.76%) ⬆️
src/goto-instrument/contracts/contracts.cpp 94.10% <100.00%> (+<0.01%) ⬆️
...nstrument/contracts/havoc_assigns_clause_targets.h 100.00% <100.00%> (ø)
src/analyses/locals.h 85.71% <0.00%> (-14.29%) ⬇️
src/solvers/lowering/byte_operators.cpp 92.60% <0.00%> (-0.11%) ⬇️
src/util/config.h 57.14% <0.00%> (ø)
jbmc/src/janalyzer/janalyzer_parse_options.cpp 48.58% <0.00%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 26d87c4...00959cc. Read the comment docs.

Copy link
Contributor

@SaswatPadhi SaswatPadhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Remi. Makes sense to me overall.

A few small comments on missing documentation / minor code changes etc.

#include <vector>

/// Stores information about a goto function computed from its CFG,
/// together with a `target` iterator into the instructions of the function.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The iterator has been removed, comment cleanup needed

Copy link
Collaborator

@feliperodri feliperodri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (considering all existing comments).

Comment on lines +110 to +109
// For goto_functions
class function_cfg_infot : public cfg_infot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: why not add the implementation of these functions on a separate .c file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's only three methods and two concrete classes, it seemed like overkill

@remi-delmas-3000 remi-delmas-3000 force-pushed the cfg-info-loops branch 2 times, most recently from 591ed94 to ddd32b4 Compare June 24, 2022 20:33
When no assigns clause was provided, we were trying to infer variables
touched by the loop and generate an assigns clause from that.
Some of these variables could be locals, which have no meaning
outside the loop, and we were trying to snapshot these variables outside
of the loop. We now detect loop locals and remove them from the inferred
frame condition the loop.
@remi-delmas-3000
Copy link
Collaborator Author

all changes made

Copy link
Contributor

@SaswatPadhi SaswatPadhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; thanks Remi!

@remi-delmas-3000 remi-delmas-3000 merged commit d46627d into diffblue:develop Jun 25, 2022
@remi-delmas-3000 remi-delmas-3000 deleted the cfg-info-loops branch June 27, 2022 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users aws-high bugfix Code Contracts Function and loop contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validity checks fail for local variables when abstracted loops are executed more than one time
4 participants