Skip to content

Symex trace: show implicit value associated with composite declarations #4964

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

Conversation

hannes-steffenhagen-diffblue
Copy link
Contributor

Previously when a struct- or other composite-typed variable was declared, symex_decl
would initialize its individual fields, then return an L2-renamed symbol relating to
the whole object. With field-sensitivity enabled, the returned symbol is e.g. my_struct!0@1#0,
while anybody reading from it will read my_struct!0@1#1..field, a different symbol which
to the solver is unrelated. The result was that in the trace, the declaration would show
up with the value of the free symbol my_struct!0@1#0 (most likely zero, since it can't be
referred to), while the rest of the trace may make it obvious that it actually had some other
non-zero value.

With this change we expand the struct into its constituent field symbols before recording an
SSA_stept for the trace. This restores the correspondence between what the trace reads and what
code reading from the struct reads.

Argument for the reviewers to have: should the goto_symex_statet::rename in symex_decl already be expanding like this? That function has an invariant insisting that it should return a single symbol, not a struct-exprt of field symbols, but that may not really be necessary. Note that if we change ::rename to always perform struct expansion then we will probably break any user that is applying this to an lvalue.

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

Previously when a struct- or other composite-typed variable was declared, symex_decl
would initialize its individual fields, then return an L2-renamed symbol relating to
the whole object. With field-sensitivity enabled, the returned symbol is e.g. my_struct!0@1#0,
while anybody reading from it will read my_struct!0@1#1..field, a different symbol which
to the solver is unrelated. The result was that in the trace, the declaration would show
up with the value of the free symbol my_struct!0@1#0 (most likely zero, since it can't be
referred to), while the rest of the trace may make it obvious that it actually had some other
non-zero value.

With this change we expand the struct into its constituent field symbols before recording an
SSA_stept for the trace. This restores the correspondence between what the trace reads and what
code reading from the struct reads.
@hannes-steffenhagen-diffblue
Copy link
Contributor Author

hannes-steffenhagen-diffblue commented Jul 30, 2019

This is copied from this PR because I will be maintaining this until it can be merged.

The test in this commit checks for a bug in which the initial nondet
assignment to struct fields was missing from --trace (always showing
these struct fields as being initialised to 0).
^SIGNAL=0$
^VERIFICATION FAILED$
--
x=\{ \.x=0 \}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally had this as a different check (checking that there was a non-zero assignment to x.x) but the cprover-smt2 run didn't produce a valid trace at all which made this test fail.

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: f458a87).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/121252412
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
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: 407c149).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/121252599

@codecov-io
Copy link

codecov-io commented Jul 30, 2019

Codecov Report

Merging #4964 into develop will decrease coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4964      +/-   ##
===========================================
- Coverage    69.29%   69.26%   -0.04%     
===========================================
  Files         1306     1307       +1     
  Lines       108263   108090     -173     
===========================================
- Hits         75023    74869     -154     
+ Misses       33240    33221      -19
Impacted Files Coverage Δ
src/goto-symex/symex_target_equation.cpp 95.16% <ø> (ø) ⬆️
src/goto-symex/symex_target_equation.h 92.3% <ø> (ø) ⬆️
src/goto-symex/symex_target.h 100% <ø> (ø) ⬆️
src/goto-symex/symex_decl.cpp 100% <100%> (ø) ⬆️
...olvers/strings/string_constraint_instantiation.cpp 90.1% <0%> (-3.3%) ⬇️
src/util/format_expr.cpp 72.18% <0%> (-3.01%) ⬇️
src/goto-symex/renaming_level.cpp 92.53% <0%> (-2.52%) ⬇️
src/cpp/cpp_declarator_converter.cpp 76.06% <0%> (-0.99%) ⬇️
jbmc/src/java_bytecode/java_bytecode_parser.cpp 89.59% <0%> (-0.98%) ⬇️
src/pointer-analysis/value_set_fi.cpp 58.42% <0%> (-0.88%) ⬇️
... and 43 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 9643ec2...407c149. Read the comment docs.

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.

5 participants