Skip to content

Byte updates using bit fields require extension to full bytes #6448

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 2 commits into from
Nov 25, 2021

Conversation

tautschnig
Copy link
Collaborator

A byte update with an update value that has a size that's not a multiple
of bytes must not overwrite bits that are not in the update value. We
previously generated extractbits expressions that would go out of
bounds, which tripped up the SMT solvers. No longer generating these
out-of-bounds expressions makes the SMT solvers happy on the Promotion3
test, which exercised this feature.

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

@codecov
Copy link

codecov bot commented Nov 9, 2021

Codecov Report

Merging #6448 (eeb1372) into develop (d39a7c5) will decrease coverage by 0.01%.
The diff coverage is 98.33%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6448      +/-   ##
===========================================
- Coverage    76.02%   76.01%   -0.02%     
===========================================
  Files         1546     1546              
  Lines       165352   165394      +42     
===========================================
+ Hits        125711   125723      +12     
- Misses       39641    39671      +30     
Impacted Files Coverage Δ
src/solvers/lowering/byte_operators.cpp 92.23% <98.07%> (+0.05%) ⬆️
src/goto-programs/string_abstraction.cpp 91.67% <98.50%> (-0.57%) ⬇️
src/goto-programs/builtin_functions.cpp 56.17% <100.00%> (ø)
src/solvers/flattening/boolbv_member.cpp 53.65% <0.00%> (-43.91%) ⬇️
src/util/format_type.cpp 49.23% <0.00%> (-15.39%) ⬇️
src/solvers/flattening/boolbv_shift.cpp 75.00% <0.00%> (-9.38%) ⬇️
src/solvers/smt2/smt2_conv.cpp 66.27% <0.00%> (-0.04%) ⬇️
src/util/simplify_expr_int.cpp 84.31% <0.00%> (+0.10%) ⬆️
... and 1 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 99c5a92...eeb1372. Read the comment docs.

@tautschnig tautschnig force-pushed the bit-updates branch 2 times, most recently from 050dc14 to 4a8b5ec Compare November 25, 2021 11:41
Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

Looks as expected. Fewer tests marked as buggy is always good.

@@ -699,7 +700,7 @@ void goto_convertt::do_havoc_slice(
t->source_location_nonconst().set_comment(
"assertion havoc_slice " + from_expr(ns, identifier, ok_expr));

const array_typet array_type(char_type(), arguments[1]);
const array_typet array_type(char_type(), simplify_expr(arguments[1], ns));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get that this might be the right thing to do and that it fixes a bug but this doesn't immediately seem linked to the description of the PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, addressed in two ways: 1) I've moved this change to a commit of its own; 2) I've added a comment explaining when a DATA_INVARIANT newly introduced here could fail (which really was what made me detect the above).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Amazing! Thank you.

The array size may include a type cast, possibly of a constant.
Therefore, the size would be found to be constant via simplification,
but other ways of computing the size may fail to derive a constant.
A byte update with an update value that has a size that's not a multiple
of bytes must not overwrite bits that are not in the update value. We
previously generated extractbits expressions that would go out of
bounds, which tripped up the SMT solvers. No longer generating these
out-of-bounds expressions makes the SMT solvers happy on the Promotion3
test, which exercised this feature.
@peterschrammel peterschrammel removed their assignment Nov 25, 2021
@tautschnig tautschnig merged commit 1afc3ae into diffblue:develop Nov 25, 2021
@tautschnig tautschnig deleted the bit-updates branch November 25, 2021 21:12
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.

4 participants