Skip to content

shift left overflow check now done in goto_check #3662

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
Jan 5, 2019
Merged

Conversation

kroening
Copy link
Member

@kroening kroening commented Jan 3, 2019

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a 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.

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: 6e68a12).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/96221565
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

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

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

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.

At least part of the implementation looks to be mistaken

^\[.*\] .* arithmetic overflow on signed shl in .*: FAILURE$
^\*\* 2 of 4 failed
^\[.*\] line 6 arithmetic overflow on signed shl in .*: FAILURE$
^\[.*\] line 9 arithmetic overflow on signed shl in .*: SUCCESS$
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps add a must-not-match for "line 12 arithmetic overflow" if that's intentionally not tested?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

neg_dist_shift =
binary_relation_exprt(op, ID_lt, from_integer(0, distance_type));

// an undefined shift of a non-zero value always results in overflow
Copy link
Contributor

Choose a reason for hiding this comment

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

an undefined shift of a non-zero value --> shifting a non-zero value by more than its width?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

binary_relation_exprt(op, ID_lt, from_integer(0, distance_type));

// an undefined shift of a non-zero value always results in overflow
const exprt undef = binary_predicate_exprt(
Copy link
Contributor

Choose a reason for hiding this comment

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

undef is defined but not used, so this probably doesn't achieve the "always overflow" behaviour the comment asks for

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, fixed

const exprt op_ext_shifted = shl_exprt(op_ext, distance);

// get top bits of the shifted operand
const exprt top_bits = extractbits_exprt(
Copy link
Contributor

Choose a reason for hiding this comment

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

? Why shift and then extract? All the bits we're interested in testing are present in the original value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Our extactbits matches the one in the SMT-LIB, and thus, only does constants.

Uses standard pattern, enables stronger typing.
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.

Thanks for the fixes, looks good except needs a case in the test for shifting more than the type width?

Daniel Kroening added 2 commits January 4, 2019 18:43
The current implementation generates an overflow-shl predicate, which is
then interpreted by the solver APIs.  This has the disadvantage that the
predicate has semantics that are both complicated and highly
language-dependent, which is not a good fit for a solver.

The new implementation defines the meaning of signed left shift overflows in
goto-check, similar as it is already done for division and unary minus.

This is covered by an existing test:
regression/cbmc/Overflow_Leftshift1/test.desc
@kroening
Copy link
Member Author

kroening commented Jan 4, 2019

ok, added

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: 4446667).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/96338889
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

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

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

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.

✔️
Passed Diffblue compatibility checks (cbmc commit: 3be9b5e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/96339556

@kroening kroening merged commit b326498 into develop Jan 5, 2019
@kroening kroening deleted the shl-overflow branch January 5, 2019 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants