Skip to content

Fix invalidation of CARs on free and DEAD instructions #6385

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 3 commits into from
Oct 7, 2021

Conversation

SaswatPadhi
Copy link
Contributor

Previously, corresponding CARs were completely removed on DEAD instructions. While this is "okay" for unconditionally dead symbols, it resulted in spurious non-assignable errors when symbols were conditionally DEAD, e.g. RETURN within a conditional block.
Previously, invalid CARs from free calls were simply left behind, because (in theory) the CAR validation condition should automatically guard against conditions.

However, in both these cases, we need to check dead/deallocated status of individual objects to avoid spurious errors from CBMC's internal pointer checks. This PR fixes this.

  • 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.
  • n/a 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.

@SaswatPadhi SaswatPadhi added bugfix aws Bugs or features of importance to AWS CBMC users aws-high Code Contracts Function and loop contracts labels Oct 6, 2021
@SaswatPadhi SaswatPadhi self-assigned this Oct 6, 2021
@SaswatPadhi SaswatPadhi force-pushed the free-dead-fix branch 3 times, most recently from baa88bd to 0b64870 Compare October 6, 2021 23:02
Copy link
Collaborator

@remi-delmas-3000 remi-delmas-3000 left a comment

Choose a reason for hiding this comment

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

With this modification the the conditional DEAD statement are correctly tracked using a condition embedded in the code rather than statically at compile time

Previously, corresponding CARs were completely removed on DEAD
instructions. While this is "okay" for unconditionally dead symbols, it
resulted in spurious non-assignable errors when symbols were only
conditionally DEAD, e.g. RETURN within a conditional block.

Previously, invalid CARs from free calls were simply left behind,
because (in theory) the CAR validation condition should automatically
guard against conditions.

However, in both these cases, we need to check dead/deallocated status
of individual objects to avoid spurious errors from CBMC's internal
pointer checks, which only track a single dead/deallocated object
nondeterministically.
@codecov
Copy link

codecov bot commented Oct 7, 2021

Codecov Report

Merging #6385 (998d141) into develop (c2c6c96) will increase coverage by 0.00%.
The diff coverage is 82.05%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #6385   +/-   ##
========================================
  Coverage    75.92%   75.93%           
========================================
  Files         1518     1518           
  Lines       164007   164040   +33     
========================================
+ Hits        124526   124565   +39     
+ Misses       39481    39475    -6     
Impacted Files Coverage Δ
src/analyses/global_may_alias.cpp 0.00% <0.00%> (ø)
src/analyses/interval_domain.h 100.00% <ø> (ø)
src/analyses/local_bitvector_analysis.cpp 74.70% <ø> (-0.15%) ⬇️
src/analyses/local_may_alias.cpp 62.96% <ø> (-0.18%) ⬇️
.../goto-instrument/accelerate/acceleration_utils.cpp 2.28% <0.00%> (+<0.01%) ⬆️
...o-instrument/accelerate/polynomial_accelerator.cpp 0.00% <0.00%> (ø)
src/goto-instrument/contracts/contracts.h 100.00% <ø> (ø)
src/goto-instrument/function_modifies.cpp 0.00% <0.00%> (ø)
src/goto-instrument/thread_instrumentation.cpp 0.00% <0.00%> (ø)
src/goto-programs/goto_program.h 90.06% <ø> (+0.75%) ⬆️
... and 21 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 01505ec...998d141. Read the comment docs.

Comment on lines +935 to +937
throw incorrect_goto_program_exceptiont(
"Found a `DEAD` variable without corresponding `DECL`!",
instruction_it->source_location);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice! We should use this instead of throw 0.

.symbol_expr();
write_set_validity_addrs.insert(object_validity_var_addr);

alias_checking_instructions.add(goto_programt::make_decl(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we be concerned that there is no test covering this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most likely a false positive from Codecov. Other statements in the same loop are covered, and there is no break or continue in between.

@SaswatPadhi SaswatPadhi merged commit bd59ad3 into diffblue:develop Oct 7, 2021
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.

4 participants