Skip to content

Prevent potential string solver failures#4489

Merged
tautschnig merged 3 commits intodiffblue:developfrom
romainbrenguier:bugfix/string-solver-nil-array
Apr 6, 2019
Merged

Prevent potential string solver failures#4489
tautschnig merged 3 commits intodiffblue:developfrom
romainbrenguier:bugfix/string-solver-nil-array

Conversation

@romainbrenguier
Copy link
Contributor

@romainbrenguier romainbrenguier commented Apr 5, 2019

Two small corrections which prevent a bug which I observed while testing the field-sensitivity branch (#2574)

  • Each commit message has a non-empty body, explaining why the change was made.
  • [na] Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • [na] The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • 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).
  • [na] 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.

@romainbrenguier romainbrenguier force-pushed the bugfix/string-solver-nil-array branch 2 times, most recently from 3d387d0 to a2273f1 Compare April 5, 2019 13:12
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.

Some nitpicks, but LGTM even if considered independently of field-sensitive symex branch.

}
const auto array = supert::get(current.get());
const auto index = get(index_expr->index());
if(array.is_nil())
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ A comment explaining why we do that would be useful (the commit message is good in that sense).

{
add_lemma(binary_relation_exprt{
string.length(), ID_ge, from_integer(0, string.length().type())});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Commit message should be changed to Constrain all generated strings to have non-negative length. I was initially confused because I thought you were excluding 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm massively surprised we didn't already have that constraint somewhere though...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A similar constraint exists in the goto-program for all non-deterministic strings generated there. But we didn't have it for new strings generated by the solver itself.

^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED
line 318 no uncaught exception: FAILURE
Copy link
Member

Choose a reason for hiding this comment

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

Can you check that the right exception is thrown?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could do that, if we didn't use --throw-runtime-exceptions but the failure I observed happened specifically when the option was used so I prefer to keep it. We could look for a particular exception in the trace, but here both NullPointerException and ArrayOutOfBoundsException could be valid counterexample traces.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Those two exceptions could still be matched by a single regular expression?

If the underlying solver does not know about the existence of an array,
it can return nil, which shouldn't be returned inside an
index_expression as in particular the type will be broken.
Generated strings should have positive length, not adding these lemmas
could potentially lead to overflow errors in check_axioms which means
the solver will end with an error because the index set is empty.
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: a2273f1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107230480
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.

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: f2fa572).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107233242
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.

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

^SIGNAL=0$
^VERIFICATION FAILED
line 318 no uncaught exception: FAILURE
--
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for these

This is an example for which a branch with changes to
symex (field-sensitivity) caused failure in the string solver because a
nil expression got into the model.
@romainbrenguier romainbrenguier force-pushed the bugfix/string-solver-nil-array branch from f2fa572 to 2c2c5ed Compare April 5, 2019 15:18
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: 2c2c5ed).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107250045
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.

@tautschnig tautschnig merged commit 14f618c into diffblue:develop Apr 6, 2019
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.

6 participants