Skip to content

JBMC: enable model and SSA equation verification #3747

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 11 commits into from
Jan 14, 2019

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Jan 10, 2019

This enables validation of the GOTO model and SSA equations in all JBMC regression tests, making the minimal modifications such that they work:

  • Fixing an accidentally untyped expression
  • Disabling basename validation for Java, which presently uses a different convention that C for name-to-basename relationship
  • Loosening type comparison to only require base_type_eq, not exact equality
  • Fixing SSA expression type verification
  • Fixing SSA DECL verification

I package these together here because this enables all these small fixes to be checked throughout the whole regression test suite, but if people prefer they can be split apart. Naturally, recommend reviewing commit by commit.

This had used a typeless symbol expression for ages without us noticing.
This invokes validation using the same arguments as CBMC.
This mirrors existing support in goto_modelt.
@smowton smowton changed the title JBMC: enable model and SSA equation JBMC: enable model and SSA equation verification Jan 10, 2019
// "method")
if(
!has_suffix(id2string(name), id2string(base_name)) &&
mode != ID_java)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe @chrisr-diffblue was also looking into this as there are also cases in C where this doesn't hold. Is this correct?

Copy link
Contributor

@chrisr-diffblue chrisr-diffblue Jan 10, 2019

Choose a reason for hiding this comment

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

Yes, I'm looking into other cases - just hadn't got as far as java yet, so Chris has saved me some work here :-)

@@ -170,7 +170,8 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
symbol_table);
const symbol_exprt &init_symbol_expression = init_symbol.symbol_expr();
code_assignt get_argument(
init_symbol_expression, symbol_exprt(this_argument.get_identifier()));
init_symbol_expression,
symbol_exprt(this_argument.get_identifier(), this_type));
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should really remove the single-argument constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In another PR, sure

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, that was not meant as a request for work.

const validation_modet vm = validation_modet::INVARIANT)
{
check(code, vm);

DATA_CHECK(
vm,
code.op0().type() == code.op1().type(),
base_type_eq(code.op0().type(), code.op1().type(), ns),
Copy link
Collaborator

Choose a reason for hiding this comment

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

To be debated with @kroening as this appears to work against the effort going on in other PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough if we want the strict same-level-of-indirection condition in the future, but we certainly don't even try to do that at present.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this commit be dropped from the PR? I understand that this would mean it doesn't work for Java at the moment, but then we can get all the other improvements in the meantime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, my intent was to use this as the means of testing the other improvements, by showing particular programs begin to satisfy this constraint when the fixes are applied, so I'd much prefer to have this statement of our current intended guarantee available, then we can chase after a future attempted standard later?

@@ -966,6 +966,8 @@ void symex_target_equationt::SSA_stept::validate(
validate_full_expr(ssa_lhs, ns, vm);
validate_full_expr(ssa_full_lhs, ns, vm);
validate_full_expr(original_full_lhs, ns, vm);
if(type == goto_trace_stept::typet::DECL)
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case I'd prefer some copy&paste and just completely separate the ASSIGNMENT and DECL cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

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

@smowton smowton force-pushed the smowton/feature/jbmc-validation branch from 88c3751 to 6db4c22 Compare January 10, 2019 15:20
Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

Not going to comment on the base_type_eq debate, but I'm happy for this to go in as it is. I'll leave the final say on base_type_eq to @tautschnig and @kroening

@smowton
Copy link
Contributor Author

smowton commented Jan 14, 2019

@tautschnig spoke with @kroening just now, who said he's happy to go for base_type_eq now (and fix everything that violates even that) and then subsequently go to ==.

@tautschnig
Copy link
Collaborator

@smowton Maybe then do a clean revert of the commit that switched from base_type_eq to == recently to make clear we are intentionally reverting this change?

They use a different pattern to that expected for C programs, and changing that will have some impact. For now
let's make validation practically usable without making a change with potentially widespread impact.
This reverts commit caae4ce.

Reverting because we can't currently meet either the weak (base_type_eq) or the strong (==) consistency requirement.
Let's target the weak one first.
@smowton smowton force-pushed the smowton/feature/jbmc-validation branch from 6db4c22 to 6274264 Compare January 14, 2019 15:51
@smowton
Copy link
Contributor Author

smowton commented Jan 14, 2019

@tautschnig done

DECL clauses do not give an RHS, so comparing its type against the LHS is meaningless (and always fails).
The expr version expects two like-structured expressions and validates subexpressions pairwise,
which is not the expected situation for VCCs.
Adding an include in a prior commit --> I must sort the other ones, apparently :)
@smowton smowton force-pushed the smowton/feature/jbmc-validation branch from 32bf0cf to 4232b15 Compare January 14, 2019 16:29
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: 4232b15).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/97290653

// Exception: Java symbols' base names do not have type signatures
// (for example, they can have name "someclass.method:(II)V" and base name
// "method")
if(!has_suffix(id2string(name), id2string(base_name)) && mode != ID_java)
Copy link
Member

Choose a reason for hiding this comment

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

Can we check that method is between . and : instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It also differs for field symbols, and generics, and... I'd like to leave (a) setting a convention and (b) enforcing it for a different PR!

@smowton smowton merged commit 9129e09 into diffblue:develop Jan 14, 2019
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