Skip to content

Validity checking of void pointers in contracts #6375

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

Closed
wants to merge 1 commit into from

Conversation

SaswatPadhi
Copy link
Contributor

PR #6365 introduced good_pointer_def checks on all pointers being deref'ed within code contracts. However, this function crashes on void pointers.

In this PR, we consider deref'ing void pointers as "invalid" as opposed to crashing.

  • 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.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

if(opt_size_of_deref.has_value())
validity_checks.push_back(good_pointer_def(pointer, ns));
else
validity_checks.push_back(false_exprt());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a comment here this could happen in case of void pointers?

Copy link
Collaborator

@jimgrundy jimgrundy left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks.

@codecov
Copy link

codecov bot commented Sep 30, 2021

Codecov Report

Merging #6375 (7f7744a) into develop (54a50e9) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 7f7744a differs from pull request most recent head 7c8b893. Consider uploading reports for the commit 7c8b893 to get more accurate results
Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #6375   +/-   ##
========================================
  Coverage    75.91%   75.91%           
========================================
  Files         1517     1517           
  Lines       164024   164026    +2     
========================================
+ Hits        124515   124517    +2     
  Misses       39509    39509           
Impacted Files Coverage Δ
src/goto-instrument/contracts/utils.cpp 91.83% <100.00%> (+0.72%) ⬆️
src/util/pointer_predicates.cpp 71.60% <100.00%> (ø)
src/util/cmdline.cpp 95.32% <0.00%> (-0.06%) ⬇️
src/util/cmdline.h 66.66% <0.00%> (ø)

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 6d77bf9...7c8b893. Read the comment docs.

@SaswatPadhi
Copy link
Contributor Author

Closing this PR after offline discussions. We would want to raise an error in this case and not ignore it as invalid.

@jimgrundy
Copy link
Collaborator

It would be neat if we could retain the change you made do src/util/pointer_predicates.cpp in whatever comes next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws-high bugfix Code Contracts Function and loop contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants