Skip to content

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

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

Closed

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Jul 17, 2019

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.

@hannes-steffenhagen-diffblue
Copy link
Contributor

This should fix #4882

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a reasonable thing to do to me, but I'd prefer if people more familiar with this part of the code could chime in.

@smowton smowton force-pushed the smowton/fix/trace-decl-initializers branch from d6492f0 to 0f37994 Compare July 23, 2019 16:47
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.
@smowton smowton force-pushed the smowton/fix/trace-decl-initializers branch from 0f37994 to 7c6370a Compare July 23, 2019 16:50
@smowton
Copy link
Contributor Author

smowton commented Jul 23, 2019

@hannes-steffenhagen-diffblue since this is your fix, would you mind taking charge of finding reviewers and addressing their comments?

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

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.

@hannes-steffenhagen-diffblue, what was the failing test? Please ping me to check how to upstream it.

@smowton
Copy link
Contributor Author

smowton commented Jul 25, 2019

@hannes-steffenhagen-diffblue you should probably also push a couple of tests representative of the problems reported to you by customers

@hannes-steffenhagen-diffblue
Copy link
Contributor

hannes-steffenhagen-diffblue commented Jul 30, 2019

Sorry for the late reply, this PR over here has a KNOWNBUG test for what's being fixed here (I did check, and the problem does indeed go away):

#4883

I'm not sure if there are other situations in which it can happen, but I don't think so.

@smowton
Copy link
Contributor Author

smowton commented Jul 30, 2019

Continued in #4964

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.

4 participants