Skip to content

Pointers to struct members #235

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
kroening opened this issue Sep 19, 2016 · 5 comments
Closed

Pointers to struct members #235

kroening opened this issue Sep 19, 2016 · 5 comments
Assignees
Labels

Comments

@kroening
Copy link
Member

Added test regression/cbmc/struct9 with 47170bd.

@smowton
Copy link
Contributor

smowton commented Oct 28, 2016

Problem is that in the double-deref (*(inner->GUARDp)) the first deref returns a byte-extract operation (since the inner aliases an outer), and then the second can't get a points-to set off of byte_extract and so returns invalid-object

@smowton
Copy link
Contributor

smowton commented Oct 28, 2016

Candidate fix in https://github.com/smowton/cbmc/tree/symex_deref_clean_struct_member, which in the case of a constant pointer offset returns an arbitrarily nested series of member-of and index-of expressions if possible, rather than resorting to byte-extract right away. That fixes the testcase posted:

Before, using the debug printing at symex_dereference.cpp:302:

**** inner!0@1
**** byte_extract_little_endian(outer!0@1, POINTER_OFFSET(inner!0@1), struct inner_struct { char *GUARDp; })

After:

**** inner!0@1
**** [email protected]

And with slight extension of the test program it can also generate expressions like:

**** inner!0@1
**** [email protected][1]

It doesn't however fix the general case where a real reinterpret case has happened, so byte-extract is perhaps the only reasonable way to express what has happened, and then further pointers are followed. At present invalid_object is offered up as a dangling nondet, hence the spurious counterexample, but I can't immediately think how to compile a program that derefs off a reinterpret except by generating a value set containing every object.

One other possible worrry: this of course introduces member_exprt where it hasn't been seen before. The rest of the code seemed to cope with these examples, but may be fragile in ways I haven't discovered yet.

@kroening
Copy link
Member Author

May I have a pull request for this, please?

@smowton
Copy link
Contributor

smowton commented Oct 31, 2016

Submitted #283

@kroening
Copy link
Member Author

kroening commented Nov 7, 2016

Merged.

@kroening kroening closed this as completed Nov 7, 2016
smowton pushed a commit to smowton/cbmc that referenced this issue May 9, 2018
…th_j2

Introducing '-j2' option to Travis builds.
chrisr-diffblue added a commit to chrisr-diffblue/cbmc that referenced this issue Aug 24, 2018
…-interval-unit-tests

Fix broken interval unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants