Skip to content

Skip phi assignment if one of the merged states has an uninitialised object [blocks: #35, #2574, #3486] #2220

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
merged 2 commits into from
Dec 19, 2018

Conversation

tautschnig
Copy link
Collaborator

With level-2 counters incremented on declaration and non-deterministic
initialisation upon allocation, the only remaining sources are pointer
dereferencing, where uninitialised objects necessarily refer to invalid objects.

This is a cleaner implementation of 369f077.

This is another bit factored out from #35.

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Should rename the PR? Since #2168 has landed in the meantime this is really just a cleanup now I think?

@tautschnig
Copy link
Collaborator Author

Should rename the PR? Since #2168 has landed in the meantime this is really just a cleanup now I think?

Not entirely: the implementation in #2168 did not yet consider the case that neither branch had SSA level2 at zero, which would occur with uninitialized globals, hence the argc/argv/envp fix in this PR before doing the "cleanup" part.

@smowton
Copy link
Contributor

smowton commented May 23, 2018

Aha, in that case can we have a test to exhibit the change here?

@tautschnig tautschnig changed the title Skip phi assignment if neither merged state has an initialised object Skip phi assignment if one of the merged states has an uninitialised object Jun 7, 2018
@tautschnig
Copy link
Collaborator Author

@smowton Apologies for the delay. I have amended the commit message, adding: "Removing only the code introduced in 369f077 would yield a wrong result for regression/cbmc/Local_out_of_scope3." -- so the test is actually already in place.

@smowton
Copy link
Contributor

smowton commented Jun 8, 2018

Cool, in that case lgtm

@tautschnig tautschnig force-pushed the phi-cleanup branch 3 times, most recently from c82bfd7 to ec8c07c Compare June 14, 2018 07:56
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: ec8c07c).

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.

A couple of clang-format complaints, otherwise good to go.

@tautschnig tautschnig removed their assignment Jun 20, 2018
@smowton
Copy link
Contributor

smowton commented Jul 5, 2018

@tautschnig is there a reason you dropped this? Looks good to go AFAICT. There were a couple of spurious Travis failures that I just restarted.

@tautschnig tautschnig changed the title Skip phi assignment if one of the merged states has an uninitialised object Skip phi assignment if one of the merged states has an uninitialised object [blocks: #35, #2574] Nov 7, 2018
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: 2311826).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/90528381

@tautschnig tautschnig force-pushed the phi-cleanup branch 4 times, most recently from 7359f23 to c7f9d6e Compare November 11, 2018 22:16
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: c7f9d6e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/90998307

@tautschnig tautschnig changed the title Skip phi assignment if one of the merged states has an uninitialised object [blocks: #35, #2574] Skip phi assignment if one of the merged states has an uninitialised object [blocks: #35, #2574, #3486] Dec 1, 2018
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: 8f1745d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/93272998

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

@tautschnig
Copy link
Collaborator Author

This now fixes even more bugs with fewer changes.

{
rhs = dest_state_rhs;
if(goto_count == 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Note the dest_count == 0 && goto_count == 0 case is forbidden above, so this implies `dest_state.guard.is_false() && dest_count != 0) -- not sure if this can be distangled to make that clearer, or perhaps clarify with a comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If dest_state.guard.is_false() then really we don't care about dest_count, because it sits on a dead branch. Any idea what you'd like the comment to say?

Copy link
Contributor

Choose a reason for hiding this comment

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

How about just pulling out

if(
  (dest_state.guard.is_false() && goto_count == 0) ||
  (goto_state.guard.is_false() && dest_count == 0))
{
  return;
}

It does mean testing is_false() multiple times, but it makes it clearer which cases are possible. Comment-wise, I guess we should add something like // If the symbol is not initialised on one path and the other path is unreachable we don't need to generate anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mind taking another look at the latest version of this PR? Your comments helped make clear which change fixes which bug!

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

In 646cf29, initialisation of dynamic objects was added, but extern
symbols were not considered. Includes a test that fails without this fix.
…object

With level-2 counters incremented on declaration and non-deterministic
initialisation upon allocation, the only remaining sources are pointer
dereferencing, where uninitialised objects necessarily refer to invalid objects.

This is a cleaner implementation of 369f077. Removing only the code
introduced in 369f077 would yield a wrong result for
regression/cbmc/Local_out_of_scope3.

Fixes: diffblue#1630
Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Looks good! I have a feeling the previous version used !is_not_nil() where the current one uses is_not_nil() (without the !), so double-check that?

@tautschnig
Copy link
Collaborator Author

Looks good! I have a feeling the previous version used !is_not_nil() where the current one uses is_not_nil() (without the !), so double-check that?

Well, one of them did... - which was a bug...

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

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.

5 participants