Skip to content

Feature nondet array initialization [blocks: #3572] #3750

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

hannes-steffenhagen-diffblue
Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue commented Jan 10, 2019

This PR adds options that let a user generate initialisation code for "dynamic" array parameters (i.e. pointers which point to an array, optionally coupled with a parameter holding their size). This is "opt-in", i.e. the user has to declare which of their function parameters are meant to be arrays (and which parameter holds the size of which array, if any).

  • 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/
  • [x ] 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.

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue changed the title Feature nondet array initialization Feature nondet array initialization [blocks: #3572] Jan 10, 2019
Copy link
Contributor

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

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

LGTM

/// \param malloc_symbol_name The name of the malloc function
const symbolt &gen_malloc_function(const irep_idt &malloc_symbol_name);

void gen_array_allocation(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get some documentation on this?

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: 2dc02c3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/96936329

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the feature-nondet-array-initialization-split branch from 2dc02c3 to 23c1ab3 Compare January 10, 2019 18: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: 23c1ab3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/96943865
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.

@kroening
Copy link
Member

This expands the command line option set too significantly -- please do in goto-instrument!

@hannes-steffenhagen-diffblue
Copy link
Contributor Author

@kroening Can you clarify what exactly you mean by that? This PR is supposed to supposed to allow modelling of array input parameters for entry points, in a similar way to how #3251 did this for structs.

Copy link
Contributor

@danpoe danpoe left a comment

Choose a reason for hiding this comment

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

LGTM (modulo getting @kroening's concern sorted)

This adds a function that generates a malloc function that replicates the
behaviour of malloc from CBMCs stdlib implementation. This is useful in
situations in which we can't rely on malloc being present.
This enables derived classes to implement their own language specific
options
Adds the
 --pointers-to-treat-as-arrays
 --associated-array-sizes
 --max-dynamic-array-size

options. The intended behaviour is that the former should indicate which of
the function parameters to an entry function that are pointers should be backed
by an array, the parameter that should hold the size of that array (if any) and
the maximum size of such an array (minimum 1) respectively.

These options currently have no effect and will be implemented in a later commit
@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the feature-nondet-array-initialization-split branch 2 times, most recently from 6cd1d6b to b53db4f Compare January 15, 2019 17:05
This implements the behaviour of the

--pointers-to-treat-as-arrays
--associated-array-sizes
--max-dynamic-array-size

options.
@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the feature-nondet-array-initialization-split branch from b53db4f to 14e8833 Compare January 15, 2019 17:52
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: b53db4f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/97425323
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.

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

@johnnonweiler
Copy link
Contributor

@kroening has suggested putting the new command line options in goto-instrument instead of cbmc.
@hannes-steffenhagen-diffblue has pointed out that this would be inconsistent with #3251. @tautschnig would you be happy for these options, and the options that were added in #3251 to be moved to goto-instrument?

@hannes-steffenhagen-diffblue
Copy link
Contributor Author

hannes-steffenhagen-diffblue commented Jan 17, 2019

To clarify: My understanding is that the idea was to create a new option to goto-instrument to create a harness for a function (i.e. something along the lines of --generate-harness <function-to-be-called>:<harness-function-name>) rather than expand the behaviour of the default harness cbmc generates, is this correct?

@danpoe
Copy link
Contributor

danpoe commented Jan 17, 2019

@kroening @tautschnig @peterschrammel As a general note, given that the entry point/harness generation is language-specific, should there be a way of specifying in goto-instrument which language feature to use? We could have an option --language=<language> and throw an invalid_command_line_argument_exceptiont when a language-specific feature that is only supported for e.g. C at the moment is used with --language=java.

@hannes-steffenhagen-diffblue
Copy link
Contributor Author

@kroening @peterschrammel

It was suggested by @tautschnig to move harness generation to a new command line tool entirely that would only do harness generation. Would you be alright with that as well?

@kroening
Copy link
Member

@hannes-steffenhagen-diffblue @johnnonweiler Indeed, #3251 should move along with this!
I would be ok with either a different tool, or adding it to goto-instrument. Did you envisage outputting that harness as goto-program or as a C program?

@hannes-steffenhagen-diffblue
Copy link
Contributor Author

I think it'd make more sense to have it take and output /change a goto binary the same way goto instrument works

@hannes-steffenhagen-diffblue
Copy link
Contributor Author

Closed as we decided to do this another way

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