Skip to content

Fix for arrays containing structs will null pointers #1009

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

Conversation

thk123
Copy link
Contributor

@thk123 thk123 commented Jun 13, 2017

We now allow finding a null pointer at any point in the removal process (previously we were just excepting it in an array of pointers). This fixes diffblue/cbmc-toyota#128

This slightly changes the behaviour in the event we can precisely resolve a null pointer. Previously we would have replaced the function pointer with a branch on all valid function pointers. Now we will (providing --pointer-check is enabled) simply assert false.

This behaviour is more desirable - if we know a pointer is NULL then the previous if statements that were generated would all be ignored anyway, so this just reduces the size of the goto program with no impact on its behaviour.

Pointers to not functions still cause a rejection, so tests that exhibit this have been modified to require this. I am not sure this is correct as I think it makes the behaviour a little inconsistent.

Between this PR and #1007 the PR #936 can be removed since the tests it adds are included in these PRs. Further - they are actually fixed!

Uninitialized entries in an array are set to zero (i.e. the struct
contains zero and a null pointer). The output should still generate the
possible valid if statements as it does with an array of function
pointers containing null (as demonstrated in
approx-const-fp-array-variable-const-fp-with-null).
@thk123 thk123 force-pushed the bugfix/arrays-structs-null-pointers branch from 6a9f22c to e7de7a6 Compare June 13, 2017 17:20
thk123 added 4 commits June 13, 2017 18:23
It is more logical that the functor operator takes the expression it is
considering as it would allow the same object to be reused for multiple
function pointer resolutions.
We now exclude the line that would catch if the function is replaced by
all 9 possibilities.
We now allow finding a null pointer at any point in the removal process
(previously we were just excepting it in an array of pointers). This
fixes diffblue/cbmc-toyota#128

This slightly changes the behaviour in the event we can precisely
resolve a null pointer. Previously we would have replaced the function
pointer with a branch on all valid function pointers. Now we will
(providing --pointer-check is enabled) simply assert false.

This behaviour is more desirable - if we know a pointer is NULL then the
previous if statements that were generated would all be ignored anyway,
so this just reduces the size of the goto program with no impact on its
behaviour.

Pointers to not functions still cause a rejection, so tests that exibit
this have been modified to require this.
@thk123 thk123 force-pushed the bugfix/arrays-structs-null-pointers branch from e7de7a6 to 8ec1890 Compare June 13, 2017 17:23
@thk123
Copy link
Contributor Author

thk123 commented Jun 13, 2017

Requesting review from @danpoe @NlightNFotis @martin-cs

Copy link
Contributor

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

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

This patch is clean in intend and in code. Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants