Skip to content

Well formedness checking goto #3188

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 4 commits into from
Dec 4, 2018

Conversation

xbauch
Copy link
Contributor

@xbauch xbauch commented Oct 16, 2018

Fills the skeleton of #3123 with additional checks of goto instructions. Each commit contains a unit test for its instruction.

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

@xbauch
Copy link
Contributor Author

xbauch commented Oct 16, 2018

Only the last 4 commits are relevant. Feel free to have a look/review/comments but form my still be adopted to potential changes to #3123.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

Generally : yes, a big step in the right direction. Comments are details although some of them are part of bigger discussions and maybe should be split out into separate issues (which was part of the point of this line of work).

void check(const validation_modet vm = validation_modet::INVARIANT) const
{
DATA_CHECK(
operands().size() == 3, "function calls must have three operands");
Copy link
Collaborator

Choose a reason for hiding this comment

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

A little more documentation? What are these three?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@sonodtt sonodtt mentioned this pull request Oct 17, 2018
6 tasks
@martin-cs
Copy link
Collaborator

Looks much better.

tautschnig added a commit that referenced this pull request Nov 9, 2018
Skeleton for well-formedness checking of goto models [blocks: #3118, #3147, #3188, #3191, #3187, #3193]
@xbauch xbauch force-pushed the well-formedness-checking-goto branch from 7c2e774 to 37e570b Compare November 13, 2018 08:33
@xbauch xbauch force-pushed the well-formedness-checking-goto branch from 66ed960 to 9447d2b Compare November 20, 2018 08:16
@xbauch xbauch assigned tautschnig and unassigned xbauch Nov 20, 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: 9447d2b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/91978074

source_location);
DATA_CHECK_WITH_DIAGNOSTICS(
!ns.lookup(to_code_decl(code).get_identifier(), table_symbol),
"declaring unknown symbol: " +

Choose a reason for hiding this comment

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

These texts seem to sometimes follow the style of "this property should hold" and other times "this property was violated". I think we should choose the same one every time (and probably prefer the former).

DATA_CHECK_WITH_DIAGNOSTICS(
!ns.lookup(to_code_dead(code).get_identifier(), table_symbol),
"removing unknown symbol: " +
id2string(to_code_dead(code).get_identifier()) + " from scope",

Choose a reason for hiding this comment

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

This part should go into the diagnostics bits instead of being part of the description (same applies to several other places).

#include <testing-utils/catch.hpp>
#include <util/arith_tools.h>

SCENARIO(

Choose a reason for hiding this comment

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

We add a unit test for the decl checks here, but not for the dead checks which were also added in the same commit

if(e.type().id() != ID_bool)
return false;
if(e.id() == ID_typecast)
return e.type().id() == ID_bool;

Choose a reason for hiding this comment

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

This is always true because of the previous if

if(e.id() == ID_exists || e.id() == ID_forall)
return true;

//weird

Choose a reason for hiding this comment

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

These are for floating point numbers I think

@@ -211,3 +211,47 @@ const exprt &object_descriptor_exprt::root_object() const

return *p;
}

bool evaluates_to_boolean(const exprt &e)

Choose a reason for hiding this comment

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

This function is defined here, but not actually used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Michael wanted it in util but Martin did not want it to be used (in this PR).

Copy link
Collaborator

Choose a reason for hiding this comment

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

So maybe it should also be removed from this PR and be added to whichever PR actually does make use of it?

@@ -1080,6 +1080,47 @@ class code_function_callt:public codet
{
return op2().operands();
}

static void check(const codet& code,
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between check, validate and validate_full?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xbauch xbauch force-pushed the well-formedness-checking-goto branch from 9447d2b to 6db85da Compare December 3, 2018 16:28
@xbauch
Copy link
Contributor Author

xbauch commented Dec 3, 2018

Addressed comments by @hannes-steffenhagen-diffblue, rebased. Will squash the excessive commits once approved.

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Just two comments about procedures.

@@ -211,3 +211,47 @@ const exprt &object_descriptor_exprt::root_object() const

return *p;
}

bool evaluates_to_boolean(const exprt &e)
Copy link
Collaborator

Choose a reason for hiding this comment

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

So maybe it should also be removed from this PR and be added to whichever PR actually does make use of it?

goto-programs/goto_program_dead.cpp \
goto-programs/goto_program_declaration.cpp \
goto-programs/goto_program_function_call.cpp \
goto-programs/goto_program_goto_target.cpp \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lexicographic ordering, please. (goto_program*<goto_trace_output)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tautschnig I fixed the ordering. As to the above evaluates_to_boolean function: that PR hasn't been made yet. I removed it from here, and will put it to a PR once we actually make it.

@tautschnig tautschnig assigned xbauch and unassigned tautschnig Dec 3, 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.

🚫
This PR failed Diffblue compatibility checks (cbmc commit: 6db85da).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/93396736
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

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

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

Petr Bauch added 4 commits December 4, 2018 08:24
Check that declared/removed symbol is known and the statement is valid.
Check that the guard evaluates to a Boolean value.
Check that returned types are matching.
Check that targets are well-formed and consistent.
@xbauch xbauch force-pushed the well-formedness-checking-goto branch from 6db85da to 2c9a5c3 Compare December 4, 2018 08:28
@xbauch xbauch merged commit 6a0cafa into diffblue:develop Dec 4, 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.

🚫
This PR failed Diffblue compatibility checks (cbmc commit: 2c9a5c3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/93477996
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

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

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

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