Skip to content

Add array initialisation support in default goto-harness. #4234

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

Conversation

NlightNFotis
Copy link
Contributor

Joint work by me and @hannes-steffenhagen-diffblue on adding support for statically and dynamically sized arrays non-deterministic initialisation on the function-call harness in the new goto-harness tool.

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

@NlightNFotis NlightNFotis force-pushed the non_det_array_goto_harness branch from c3fed2e to 071a1f9 Compare February 20, 2019 16:37
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll also need to update user documentation ideally with usage examples and current limitations (no support for globals and struct members for dynamic arrays atm)

@@ -42,6 +43,12 @@ struct function_call_harness_generatort::implt
recursive_initialization_configt recursive_initialization_config;
std::unique_ptr<recursive_initializationt> recursive_initialization;

std::set<irep_idt> function_parameters_to_treat_as_arrays;
std::set<irep_idt> function_arguments_to_treat_as_arrays;

Choose a reason for hiding this comment

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

I don't particularly enjoy the solution we have here - basically, we need to keep track of the names of function arguments as declared on the function, and their mapping to parameters, and which parameters the array initialisation applies to etc...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a note, we don't need to do it right now.

@@ -37,7 +38,16 @@ void recursive_initializationt::initialize(
}
else if(type.id() == ID_pointer)
{
initialize_pointer(lhs, depth, known_tags, body);
if(

Choose a reason for hiding this comment

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

This could have been solved more elegantly if we used a handler chain pattern as the test-gen team does for their harness generation. Didn't want to do this atm because this was mostly about porting existing functionality, but might be worth converting this at some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a note, we don't need to do it right now.

Copy link
Contributor

@xbauch xbauch 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.

@sonodtt
Copy link
Contributor

sonodtt commented Feb 21, 2019

We'll also need to update user documentation ideally with usage examples and current limitations (no support for globals and struct members for dynamic arrays atm)

Superb. The less time anyone needs to spend 'reverse-engineering' context/boundary conditions/ edge case coverage - is all company time that can be used for other purposes. A huge win at little cost.
To some extent - the same applies to a PR - in general the less assumptions made about people knowing what is in/ "the purpose" / "edge conditions" of a PR the better. I recall also external contributors making the same point.

I am delighted to see that you're keeping this in mind (& I know Fotis also shares this perspective).

@hannes-steffenhagen-diffblue
Copy link
Contributor

hannes-steffenhagen-diffblue commented Feb 25, 2019

Note that some of the examples don’t quite work atm due to a bug that has a pending fix in another PR

#4277

@NlightNFotis NlightNFotis force-pushed the non_det_array_goto_harness branch 2 times, most recently from 078f14b to 9b6a4b2 Compare February 25, 2019 17:23
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.

A couple of comments, but also a rebase and making-CI-happy is required.

@NlightNFotis NlightNFotis force-pushed the non_det_array_goto_harness branch from 9b6a4b2 to 0ad43fd Compare February 26, 2019 14:15
NlightNFotis and others added 2 commits February 26, 2019 15:00
for the function we are calling in goto-harness. Before this
we had a function called setup_parameters_and_call_entry_function,
and now we have split it up into declare_arguments and call_function.
This is so we can do some handling between declaring arguments
and calling the function.

Co-authored-by: Fotis Koutoulakis <[email protected]>
Co-authored-by: Hannes Steffenhagen <[email protected]>
Add non-det initialization of statically sized arrays.
This does element-wise initialisation.

Co-authored-by: Fotis Koutoulakis <[email protected]>
Co-authored-by: Hannes Steffenhagen <[email protected]>
@NlightNFotis NlightNFotis force-pushed the non_det_array_goto_harness branch from 0ad43fd to 151dfd2 Compare February 26, 2019 15:00
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: 0ad43fd).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102341655
Status will be re-evaluated on next push.
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 compatibility was already broken by an earlier merge.

@NlightNFotis NlightNFotis force-pushed the non_det_array_goto_harness branch from 151dfd2 to 07c31d7 Compare February 26, 2019 15:20
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: 151dfd2).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102349568
Status will be re-evaluated on next push.
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 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.

✔️
Passed Diffblue compatibility checks (cbmc commit: 07c31d7).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102353668

@NlightNFotis NlightNFotis force-pushed the non_det_array_goto_harness branch from 07c31d7 to 5904fec Compare February 27, 2019 10:44
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: 5904fec).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102477427

NlightNFotis added a commit to NlightNFotis/cbmc that referenced this pull request Feb 27, 2019
NlightNFotis added a commit to NlightNFotis/cbmc that referenced this pull request Feb 27, 2019
@NlightNFotis NlightNFotis force-pushed the non_det_array_goto_harness branch from 5904fec to 1be00d6 Compare February 27, 2019 14:45
Copy link
Contributor

@LAJW LAJW left a comment

Choose a reason for hiding this comment

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

Rough.

That random argument-dependent-static variable is VERY suspicious.

Small helper to convert a program argument to
size_t and throw an exception if it doesn't work.

Co-authored-by: Fotis Koutoulakis <[email protected]>
Co-authored-by: Hannes Steffenhagen <[email protected]>
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: 1be00d6).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102514471

@NlightNFotis NlightNFotis force-pushed the non_det_array_goto_harness branch 2 times, most recently from c248ef3 to 8b2d421 Compare February 27, 2019 16:46
NlightNFotis and others added 3 commits February 27, 2019 17:17
Create and non-det initialise of pointers to arrays
making sure that they actually point at arrays. Also
allows binding function parameters to the size of the
array parameter. Only works with function parameters
at the moment, not with struct members or globals. Also
adds tests.

Co-authored-by: Fotis Koutoulakis <[email protected]>
Co-authored-by: Hannes Steffenhagen <[email protected]>
Added a debugging helper function. It was worth
keeping it around even after debugging.

Co-authored-by: Fotis Koutoulakis <[email protected]>
Co-authored-by: Hannes Steffenhagen <[email protected]>
This adds some user documentation to goto-harness. Currently only includes
documentation for the call-function harness, not the memory-snapshot harness
@NlightNFotis NlightNFotis force-pushed the non_det_array_goto_harness branch from 8b2d421 to 0ea5c31 Compare February 27, 2019 17:18
@@ -23,5 +23,11 @@ if [ -e "${name}-mod.gb" ] ; then
rm -f "${name}-mod.gb"
fi

$goto_harness "${name}.gb" "${name}-mod.gb" --harness-function-name $entry_point ${args}
$cbmc --function $entry_point "${name}-mod.gb" --unwind 20 --unwinding-assertions
# `# some comment` is an inline comment - basically, cause bash to execute an empty command
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@@ -31,6 +31,8 @@ struct recursive_initialization_configt
std::set<irep_idt> pointers_to_treat_as_arrays;
std::set<irep_idt> variables_that_hold_array_sizes;
std::map<irep_idt, irep_idt> array_name_to_associated_array_size_variable;

std::string to_string() const; // for debugging purposes
Copy link
Contributor

Choose a reason for hiding this comment

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

If to_string() is only meant to be used for debugging purposes, is it worth wrapping it in #if DEBUG ?


We have two types of harnesses we can generate for now:

* The `memory-snapshot` harness. TODO: Daniel can document this.
Copy link
Contributor

Choose a reason for hiding this comment

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

There's more than one 'Daniel'....

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe explicitly reference the PR (#4261)?

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

@NlightNFotis NlightNFotis merged commit b3cc3e9 into diffblue:develop Feb 28, 2019
@NlightNFotis NlightNFotis deleted the non_det_array_goto_harness branch February 28, 2019 10:49
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.

8 participants