Skip to content

Bugfix/char array in string solver #3248

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

Conversation

romainbrenguier
Copy link
Contributor

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

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.

Looks ok to me.

@smowton
Copy link
Contributor

smowton commented Oct 29, 2018

A fix suggests a regression test?

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.

I agree with @smowton . It is not obvious what the effect of the bug fix is. It would be nice to have at least one test that is wrong before and right afterwards just to make clear one of the higher-level effects of this.

@romainbrenguier romainbrenguier force-pushed the bugfix/char-array-in-string-solver branch from 14268da to 3129270 Compare October 30, 2018 07:59
@romainbrenguier
Copy link
Contributor Author

@smowton @martin-cs I agree that this PR should have tests, and I tried adding some but couldn't manage to do it in two days of work. The issue appears on another of our tool and I couldn't reproduce with JBMC, (the example uses --cover location which no longer exists in JBMC). Unit tests will be good but I encounter lot of bugs in the different layers of the solvers when the formulas don't come from a goto-program but are hand-written for the unit test. I have a PR that add tests for this fix in another of our repository https://github.com/diffblue/test-gen/pull/2428
I want look a bit more in depth at the bugs I encounter while writing unit testing, and write tests for each layers but this will require more time.

@tautschnig
Copy link
Collaborator

To keep effort reasonable I'd say it's ok if there are regression tests elsewhere.

@romainbrenguier romainbrenguier force-pushed the bugfix/char-array-in-string-solver branch from 3129270 to 1dc3227 Compare October 30, 2018 09:06
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: 3129270).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/89619587
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.

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

Copy link
Contributor

@thk123 thk123 left a comment

Choose a reason for hiding this comment

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

I agree it would be better to see a regression added as part of this PR too

@@ -36,7 +36,7 @@ class tt
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ typo in commit message:

We The way it was used was inconsistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

First sentence also has some problems.

@@ -21,10 +21,10 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com
#include "std_expr.h"

refined_string_typet::refined_string_typet(
const typet &index_type, const typet &char_type)
const typet &index_type,
const typet &content_type)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does content_type need to be a pointer_typet? If so, perhaps make this only except a pointer_typet

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.

I think this makes sense though I'm worried about maintainability. Somehow it should be clear why we have to do the array replacement there and I find the inline comment a bit vague. I suggest extracting that into a separate function.

@@ -36,7 +36,7 @@ class tt
}
Copy link
Contributor

Choose a reason for hiding this comment

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

First sentence also has some problems.

@romainbrenguier romainbrenguier force-pushed the bugfix/char-array-in-string-solver branch from 1dc3227 to cc6e0f9 Compare October 31, 2018 09:59
@romainbrenguier romainbrenguier force-pushed the bugfix/char-array-in-string-solver branch from cc6e0f9 to 959d680 Compare October 31, 2018 10:22
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: 959d680).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/89785978

@romainbrenguier romainbrenguier force-pushed the bugfix/char-array-in-string-solver branch from 959d680 to 58e6339 Compare November 1, 2018 07:13
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: 58e6339).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/89913124

/// Similar to `symbol_resolve.replace_expr` but doesn't mutate the expression
/// and return the transformed expression instead.
static exprt
transform_expr(const union_find_replacet &symbol_resolve, exprt expr)
Copy link
Contributor

Choose a reason for hiding this comment

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

exprt-> equal_exprt (in the doc you mention equations)

Copy link
Contributor

Choose a reason for hiding this comment

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

That's more or less what I had in mind. However transform_expr sounds like do_something_to_expr. 😄
How about substitute_with_repr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would keep transform as it is used in the standard library for operations without side-effects https://en.cppreference.com/w/cpp/algorithm/transform

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah but in std::transform you give the operation as argument, so the generic name makes sense there. Not here, because the caller doesn't know what the operation is.

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 you are right, but instead of having a "substitute" and a "replace" function name (difficult to see which one is which from the name), I suggest to name this one replace_expr_copy (following the _copy pattern of the stl), making it clear that this one creates a new copy of the expression.

/// Substitute sub-expressions in equation by representative elements of
/// `symbol_resolve` whenever possible.
/// Similar to `symbol_resolve.replace_expr` but doesn't mutate the expression
/// and return the transformed expression instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ return -> returns

dependencies,
eq_with_char_array_replaced_with_representative_elements,
generator.array_pool);
if(!node_added)
Copy link
Contributor

Choose a reason for hiding this comment

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

That's much clearer to me. Thanks!

No functional changes
The data should be kept between calls to dec_solve because the set of
equations from the last call are not recorded.
In the string refinement we replace symbols corresponding to arrays of
characters by cannonical element to ensure that symbols resolving to the
same expression are associated the same node.

We should not replace char array in equations that are passed to supert,
since the underlying solver should handle pointers and arrays, and
string_refinementt should not interfer with it.
We make the second argument be the content type. This is more
compatible, and is how it is used at least once in the code base.
The way it was used was inconsistent.
@romainbrenguier romainbrenguier force-pushed the bugfix/char-array-in-string-solver branch from 58e6339 to 33b005c Compare November 2, 2018 07:21
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: 33b005c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/90046786

@romainbrenguier romainbrenguier merged commit 64ec195 into diffblue:develop Nov 5, 2018
@romainbrenguier romainbrenguier deleted the bugfix/char-array-in-string-solver branch November 5, 2018 09:25
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.

7 participants