Skip to content

[TG-9400][UFC] Add an assume-no-exceptions-thrown option #5117

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

romainbrenguier
Copy link
Contributor

This adds an option to JBMC to replace throw instructions by assert(false);assume(false);
so that execution branches are not analyzed further than the first throw.
This is mostly useful for performances, but the full benefit of this will only show once #5097 is in.

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

@romainbrenguier romainbrenguier force-pushed the experiment/never-throw branch 4 times, most recently from da9ea98 to 6f13cc5 Compare September 20, 2019 18:08
@romainbrenguier romainbrenguier added the Needs TG approval 🦉 Only merge with explicit approval from test-gen maintainers label Sep 20, 2019
@romainbrenguier romainbrenguier force-pushed the experiment/never-throw branch 3 times, most recently from c31ece6 to ebe53cd Compare September 20, 2019 20:39
@smowton
Copy link
Contributor

smowton commented Sep 21, 2019

I note this doesn't quite do what it says: it actually asserts that no exception is thrown, rather than assuming it (TG of course also uses --cover, translating that into an assumption)

@romainbrenguier romainbrenguier changed the title [TG-9400][UFC] Add an assume-no-exceptions-throw exceptions [TG-9400][UFC] Add an assume-no-exceptions-thrown option Sep 23, 2019
@romainbrenguier
Copy link
Contributor Author

@smowton

I note this doesn't quite do what it says: it actually asserts that no exception is thrown, rather than assuming it (TG of course also uses --cover, translating that into an assumption)

It actually does both if I'm not mistaken. Should we rename the option to --assert-no-exceptions-thrown?

@romainbrenguier romainbrenguier force-pushed the experiment/never-throw branch 2 times, most recently from 755de11 to e5ba652 Compare September 23, 2019 07:58
@codecov-io
Copy link

codecov-io commented Sep 23, 2019

Codecov Report

Merging #5117 into develop will decrease coverage by <.01%.
The diff coverage is 96.36%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5117      +/-   ##
===========================================
- Coverage    66.97%   66.96%   -0.01%     
===========================================
  Files         1146     1146              
  Lines        93736    93721      -15     
===========================================
- Hits         62778    62761      -17     
- Misses       30958    30960       +2
Flag Coverage Δ
#cproversmt2 42.68% <ø> (+0.01%) ⬆️
#regression 63.45% <96.36%> (-0.01%) ⬇️
#unit 31.92% <85.45%> (+0.01%) ⬆️
Impacted Files Coverage Δ
...java_bytecode/java_bytecode_convert_method_class.h 100% <ø> (ø) ⬆️
...src/java_bytecode/java_bytecode_convert_method.cpp 97.54% <100%> (ø) ⬆️
jbmc/src/java_bytecode/java_bytecode_language.h 78.57% <100%> (+1.64%) ⬆️
jbmc/src/java_bytecode/java_bytecode_language.cpp 93.17% <95.83%> (+0.09%) ⬆️
src/nonstd/optional.hpp 96.2% <0%> (-1.24%) ⬇️
src/solvers/prop/prop_conv_solver.cpp 80.88% <0%> (-0.45%) ⬇️
src/goto-symex/goto_symex.cpp 99.44% <0%> (-0.07%) ⬇️
src/goto-symex/goto_symex.h 92.3% <0%> (ø) ⬆️

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 2af983d...6990f9b. Read the comment docs.

@romainbrenguier romainbrenguier removed the Needs TG approval 🦉 Only merge with explicit approval from test-gen maintainers label Sep 23, 2019
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: e5ba652).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/128707994
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.

@smowton
Copy link
Contributor

smowton commented Sep 23, 2019

Yes I think that's better (the assert/assume pattern matches what the Java frontend does for null-pointer derefs for example)

Copy link
Member

@peterschrammel peterschrammel left a comment

Choose a reason for hiding this comment

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

lgtm

@romainbrenguier romainbrenguier force-pushed the experiment/never-throw branch 4 times, most recently from 613b639 to 2d4842f Compare September 23, 2019 14:44
@@ -150,6 +154,56 @@ class lazy_class_to_declared_symbols_mapt
std::unordered_multimap<irep_idt, symbolt> map;
};

struct java_bytecode_language_optionst
{
explicit java_bytecode_language_optionst(
Copy link
Member

Choose a reason for hiding this comment

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

explicit not required

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: 2d4842f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/128776632
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.

@romainbrenguier romainbrenguier force-pushed the experiment/never-throw branch 2 times, most recently from 36b605c to 6990f9b Compare September 25, 2019 05:50
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: 6990f9b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/129047220
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.

Extract java_bytecode_language_optionst class from
java_bytecode_language class, to make it more structured by separating
the fields that are expected to remain constant during the execution
once they are initialized.
This is to specify that we want to replace all throw instructions by
assert false.
This is useful mainly for performance reasons as it simplifies
conditions for symex, while retaining the non-exceptional behaviour of
the program.
This tests the option behaves as desired.
Test that when both are combined, --throw-runtime-exception still
works.
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: b433f5c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/129121599
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.

Copy link

@segun3d segun3d left a comment

Choose a reason for hiding this comment

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

QA is satisfied with this PR

@romainbrenguier romainbrenguier merged commit 9171c86 into diffblue:develop Sep 25, 2019
@romainbrenguier romainbrenguier deleted the experiment/never-throw branch September 25, 2019 15:20
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.

6 participants