Skip to content

Properly checks struct members in alias expression #6265

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 7 commits into from
Aug 4, 2021

Conversation

feliperodri
Copy link
Collaborator

  • 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).
  • 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.

@feliperodri feliperodri added bugfix aws Bugs or features of importance to AWS CBMC users Code Contracts Function and loop contracts labels Aug 3, 2021
@feliperodri feliperodri requested a review from SaswatPadhi August 3, 2021 03:53
@feliperodri feliperodri self-assigned this Aug 3, 2021
@feliperodri feliperodri requested a review from tautschnig as a code owner August 3, 2021 03:53
Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

The code looks fairly good but I am worried about the tests and about disabling so many of them in a PR claiming to fix things.

@feliperodri feliperodri force-pushed the fix-assigns-for-structs branch from 5e6a202 to 7c2617a Compare August 4, 2021 04:46
@feliperodri
Copy link
Collaborator Author

The code looks fairly good but I am worried about the tests and about disabling so many of them in a PR claiming to fix things.

@martin-cs could you take another look? I fixed the bug when dealing with arrays.

@feliperodri feliperodri requested a review from martin-cs August 4, 2021 04:47
@feliperodri feliperodri force-pushed the fix-assigns-for-structs branch 2 times, most recently from 993d5a5 to ce9f270 Compare August 4, 2021 05:26
@feliperodri feliperodri changed the title Fixes alias expression to handle structs correctly Properly checks struct members in alias expression Aug 4, 2021
@codecov
Copy link

codecov bot commented Aug 4, 2021

Codecov Report

Merging #6265 (5daa210) into develop (dbb5163) will increase coverage by 0.00%.
The diff coverage is 97.96%.

❗ Current head 5daa210 differs from pull request most recent head 9e8dd91. Consider uploading reports for the commit 9e8dd91 to get more accurate results
Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #6265   +/-   ##
========================================
  Coverage    75.90%   75.90%           
========================================
  Files         1492     1492           
  Lines       162724   162731    +7     
========================================
+ Hits        123513   123522    +9     
+ Misses       39211    39209    -2     
Impacted Files Coverage Δ
jbmc/src/jdiff/jdiff_parse_options.h 100.00% <ø> (ø)
src/goto-analyzer/goto_analyzer_parse_options.cpp 71.98% <ø> (ø)
src/goto-cc/goto_cc_languages.cpp 100.00% <ø> (ø)
src/goto-diff/goto_diff_parse_options.h 100.00% <ø> (ø)
src/goto-harness/goto_harness_parse_options.cpp 68.37% <ø> (ø)
...rc/goto-instrument/goto_instrument_parse_options.h 100.00% <ø> (ø)
...rc/memory-analyzer/memory_analyzer_parse_options.h 100.00% <ø> (ø)
src/solvers/smt2_incremental/smt_sorts.cpp 94.11% <ø> (ø)
src/solvers/smt2_incremental/smt_sorts.h 100.00% <ø> (ø)
src/solvers/smt2_incremental/smt_terms.cpp 94.44% <ø> (ø)
... and 39 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 3ebacfe...9e8dd91. Read the comment docs.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

Thank you; that is a massive improvement on the previous version.

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.

I am still thinking about the new conditions we have added, but my main comment for now is to add enough test cases that cover this new change.

  1. We are missing test cases for replacement context. We should check that during replacement, we don't havoc more than (the struct field) we are supposed to havoc
  2. Both test cases assign to the first field of the struct. Since we look at the offsets etc, could we make one of the test assign to the second field? I'd suggest changing regression/contracts/assigns_enforce_structs_04/main.c to assign to p->y instead.

@feliperodri feliperodri force-pushed the fix-assigns-for-structs branch from ce9f270 to 25feb4f Compare August 4, 2021 18:32
@feliperodri
Copy link
Collaborator Author

1. We are missing test cases for replacement context. We should check that during replacement, we don't havoc more than (the struct field) we are supposed to havoc

This PR is only for enforcement. We should add test cases for replacement once we update the havoc method.

2. Both test cases assign to the first field of the struct. Since we look at the offsets etc, could we make one of the test assign to the second field? I'd suggest changing `regression/contracts/assigns_enforce_structs_04/main.c` to assign to `p->y` instead.

I added two new test cases, could you take another look? @SaswatPadhi

@feliperodri feliperodri requested a review from SaswatPadhi August 4, 2021 18:53
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, LGTM. If you rebase on to develop, you could remove some repeated code. Commented below:

@feliperodri feliperodri force-pushed the fix-assigns-for-structs branch from 5daa210 to 9e8dd91 Compare August 4, 2021 20:11
@feliperodri feliperodri merged commit e1e84da into diffblue:develop Aug 4, 2021
@feliperodri feliperodri deleted the fix-assigns-for-structs branch August 4, 2021 20:54
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 bugfix Code Contracts Function and loop contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants