Skip to content

Insert final assert false pass #4985

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

Conversation

nchong-at-aws
Copy link
Contributor

@nchong-at-aws nchong-at-aws commented Aug 5, 2019

A goto-instrument pass that adds assert(false) to the end of a function body---usually expected to be the test harness. If verification still passes then this might indicate inconsistent assumptions. Useful as an automatic check for vacuous proofs.

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

Copy link
Collaborator

@karkhaz karkhaz 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 for this instrumentation pass, it will be very useful!

Apart from the comments, please could you have a go at writing a regression test? You already wrote a few small programs while creating this patch, it should be reasonably easy to adapt them to a test somewhere under the regression/ directory.

@kroening
Copy link
Member

kroening commented Aug 5, 2019

@nchong-at-aws The way people usually check whether there are inconsistent assumptions is using --cover location. Is that good for your use-case?

@karkhaz
Copy link
Collaborator

karkhaz commented Aug 6, 2019

@kroening many of our proofs don't have 100% coverage, for various valid reasons. If using --cover, we would need to check for sudden drops in coverage, rather than checking for less-than-100%. That implies that we need to save the state of the previous coverage check.

@nchong-at-aws's patch is thus very useful because it provides a stateless way of alerting on inconsistent assumptions.

This check is also much simpler and much more black-or-white. There can be nuanced reasons for less-than-100% coverage. But it is certainly a bad sign if code instrumented with this pass successfully verifies, no doubt about it.

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

No further comments besides @karkhaz's. From a UI perspective, would --assert-function-does-not-terminate make more sense, since that's what we're actually introducing?

@nchong-at-aws
Copy link
Contributor Author

@kroening Yes, cover is useful for seeing this problem too. This check is another way to sanity check a result.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 11c2f8a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/123517019
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

@nchong-at-aws
Copy link
Contributor Author

@allredj I think this could be because I'm a first time contributor?

@kroening
Copy link
Member

This is now getting ready to merge -- may I suggest that you squash the commits into one.

@allredj
Copy link
Contributor

allredj commented Aug 19, 2019

@nchong-at-aws Very probably. You can ignore the message.

This option takes a function name (usually the test harness entry point) and
inserts `assert(false)` at the end of the function body. This assertion is
*expected to fail*. If it passes then this may indicate that the test harness
has inconsistent assumptions. Note that there are other reasons why the assert
may pass (such as insufficient loop unwind depth). It is up to the user to
interpret the results.
@smowton
Copy link
Contributor

smowton commented Aug 19, 2019

@nchong-at-aws looks like this is good to go, please squash commits

@nchong-at-aws nchong-at-aws force-pushed the insert-final-assert-false-pass branch from 11c2f8a to 639ef81 Compare August 19, 2019 13:44
@codecov-io
Copy link

Codecov Report

Merging #4985 into develop will decrease coverage by 0.23%.
The diff coverage is 88.88%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4985      +/-   ##
===========================================
- Coverage    69.48%   69.24%   -0.24%     
===========================================
  Files         1310     1311       +1     
  Lines       108813   108471     -342     
===========================================
- Hits         75609    75112     -497     
- Misses       33204    33359     +155
Impacted Files Coverage Δ
...rc/goto-instrument/goto_instrument_parse_options.h 100% <ø> (ø) ⬆️
src/goto-instrument/insert_final_assert_false.h 100% <100%> (ø)
.../goto-instrument/goto_instrument_parse_options.cpp 56.66% <100%> (+0.39%) ⬆️
src/goto-instrument/insert_final_assert_false.cpp 81.81% <81.81%> (ø)
unit/testing-utils/require_expr.cpp 0% <0%> (-34.38%) ⬇️
src/solvers/prop/bdd_expr.cpp 60.97% <0%> (-29.57%) ⬇️
...bytecode_convert_method/convert_invoke_dynamic.cpp 76.44% <0%> (-23.08%) ⬇️
src/solvers/bdd/bdd_miniBDD.h 84.61% <0%> (-15.39%) ⬇️
src/solvers/bdd/miniBDD/miniBDD.inc 93.47% <0%> (-6.53%) ⬇️
...nit/java-testing-utils/require_goto_statements.cpp 92.61% <0%> (-6.05%) ⬇️
... and 83 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 3e42990...639ef81. Read the comment docs.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 639ef81).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/123735093
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

@karkhaz karkhaz merged commit 8c7609e into diffblue:develop Aug 19, 2019
@nchong-at-aws nchong-at-aws deleted the insert-final-assert-false-pass branch August 19, 2019 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants