Skip to content

[RFC] Two new failing tests demonstrating updates outside member bounds #6101

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

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

tautschnig
Copy link
Collaborator

These examples write to a member different from the access path being
used, yet within the object bounds.

  • 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 May 10, 2021

Codecov Report

Merging #6101 (b980f1f) into develop (4c14789) will decrease coverage by 0.20%.
The diff coverage is 57.50%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6101      +/-   ##
===========================================
- Coverage    74.52%   74.32%   -0.21%     
===========================================
  Files         1447     1447              
  Lines       157808   157913     +105     
===========================================
- Hits        117610   117370     -240     
- Misses       40198    40543     +345     
Impacted Files Coverage Δ
src/goto-symex/symex_config.h 100.00% <ø> (ø)
src/goto-symex/symex_assign.cpp 65.17% <47.95%> (-14.37%) ⬇️
src/cbmc/cbmc_parse_options.cpp 77.27% <100.00%> (+0.09%) ⬆️
src/goto-symex/symex_main.cpp 86.04% <100.00%> (+0.03%) ⬆️
src/solvers/flattening/boolbv_index.cpp 89.72% <100.00%> (+10.77%) ⬆️
src/solvers/lowering/byte_operators.cpp 92.13% <100.00%> (+0.34%) ⬆️
src/util/cmdline.cpp 69.94% <0.00%> (-25.44%) ⬇️
src/ansi-c/c_typecheck_base.cpp 55.92% <0.00%> (-22.32%) ⬇️
src/ansi-c/scanner.l 40.45% <0.00%> (-21.28%) ⬇️
src/ansi-c/literals/convert_character_literal.cpp 53.84% <0.00%> (-17.95%) ⬇️
... and 21 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 8f30441...b980f1f. Read the comment docs.

@tautschnig tautschnig marked this pull request as draft May 10, 2021 15:01
@tautschnig tautschnig force-pushed the member-bounds branch 2 times, most recently from 97c41eb to 6e6affd Compare May 10, 2021 21:46
@tautschnig tautschnig added the RFC Request for comment label May 10, 2021
@tautschnig tautschnig changed the title Two new failing tests demonstrating updates outside member bounds [RFC] Two new failing tests demonstrating updates outside member bounds May 10, 2021
@tautschnig
Copy link
Collaborator Author

tautschnig commented May 10, 2021

I'm marking this RFC as I'd appreciate some thoughts about those tests. While they work perfectly fine with both gcc and clang, I'm not sure they are covered by the C standard.

@tautschnig tautschnig self-assigned this May 10, 2021
Arrays of arrays of non-constant size (as found in
regression/cbmc/Multi_Dimensional_Array6) can still be lowered by the
more general lowering code, although doing so is expensive.
These examples write to a member different from the access path being
used, yet within the object bounds.
If using the new option --symex-no-member-bounds, goto-symex will
rewrite all indexed writes that constant propagation does not show to be
within bounds to writes to the member object.
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.

I think this falls in the general area of "defining undefined behaviour". The out-of-bound write is UB so, as much as ISO 9899 has anything to say... whatever we do after is correct. I think the most important thing is that we can detect this happening. Apart from that ... emulating popular compilers is probably not a bad idea.

int A[3];
_Static_assert(sizeof(A) == sizeof(struct S), "");
struct S *s = A;
s->a[2] = 42;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pretty sure this is undefined behaviour...

@kroening
Copy link
Member

I am afraid that "access beyond member bounds" needs to be enabled by default. It's not an uncommon idiom at all.

@tautschnig
Copy link
Collaborator Author

I am afraid that "access beyond member bounds" needs to be enabled by default. It's not an uncommon idiom at all.

I'll try to work out a fix. The proposed patch only partly addresses the problem, we'll need to disable field sensitivity when detecting such an access beyond member bounds.

tautschnig added a commit to tautschnig/cbmc that referenced this pull request May 14, 2022
The option --no-simplify should be honoured by field sensitivity. This
also made apparent that we have tests that only pass thanks to the
simplifier, and perhaps aren't even expected to pass. See diffblue#6101 for
further discussion.
tautschnig added a commit to tautschnig/cbmc that referenced this pull request May 25, 2022
The option --no-simplify should be honoured by field sensitivity. This
also made apparent that we have tests that only pass thanks to the
simplifier, and perhaps aren't even expected to pass. See diffblue#6101 for
further discussion.
tautschnig added a commit to tautschnig/cbmc that referenced this pull request May 26, 2022
The option --no-simplify should be honoured by field sensitivity. This
also made apparent that we have tests that only pass thanks to the
simplifier, and perhaps aren't even expected to pass. See diffblue#6101 for
further discussion.
tautschnig added a commit to tautschnig/cbmc that referenced this pull request Jun 1, 2022
The option --no-simplify should be honoured by field sensitivity. This
also made apparent that we have tests that only pass thanks to the
simplifier, and perhaps aren't even expected to pass. See diffblue#6101 for
further discussion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request for comment Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants