Skip to content

Recursive nondet init of pointers to structs [blocks: #3443] #3251

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 10 commits into from
Nov 27, 2018

Conversation

danpoe
Copy link
Contributor

@danpoe danpoe commented Oct 31, 2018

  • 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.
  • 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).
  • n/a 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.


#include <util/object_factory_parameters.h>

struct java_object_factory_parameterst final : public object_factory_parameterst
Copy link
Member

Choose a reason for hiding this comment

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

Why this if they are the same?

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 would be a place to add options in the future that are not common to both the C and Java object factory. For C at least we expect some special options (e.g., to indicate which length function argument corresponds to which array function arguments).

@@ -51,6 +30,13 @@ class symbol_factoryt
const bool assume_non_null;
namespacet ns;

const symbolt &c_new_tmp_symbol(
Copy link
Member

Choose a reason for hiding this comment

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

Why can't this use util/fresh_symbol?

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, this should probably be replaced by a call to get_fresh_aux_symbol() since it's called in one place only.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't see anything wrong with this, but I'll need some more time to look over this before I can approve


\*******************************************************************/

#include "java_object_factory_parameters.h"

Choose a reason for hiding this comment

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

Why is this in a commit called "move object factory parameters to util"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, renamed the commit to "Move object factory parameters to util and add java object factory parameters" (plus a body with some more details).

@@ -922,6 +923,8 @@ void cbmc_parse_optionst::help()
" --round-to-plus-inf rounding towards plus infinity\n"
" --round-to-minus-inf rounding towards minus infinity\n"
" --round-to-zero rounding towards zero\n"
" --max-nondet-tree-depth N limit size of nondet (e.g. input) object tree;\n" /* NOLINT(*) */ \

Choose a reason for hiding this comment

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

We should have some more detailed description of how this behaves in our docs

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've updated the documentation in object_factory_parameters.h for the max_nondet_tree_depth parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

That helps, but it's not user visible, and even for us it's going to take some digging to find out that this parameter does end up there if we ever need to find out

(This is a reply to one of @danpoe 's other comments, but doesn't show up as such in github. Thanks github).

Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely agree that this could do with some user documentation and not just source code documentation.

@@ -0,0 +1,17 @@
#include <assert.h>

Choose a reason for hiding this comment

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

Could the tests get better names than "pointer-function-parameters-{3,4,5,6}"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, renamed.

@danpoe danpoe force-pushed the feature/nondet-init-structs branch 5 times, most recently from 114a027 to 102199d Compare November 2, 2018 11:06

if(
recursion_set.find(struct_tag) != recursion_set.end() &&
depth >= object_factory_params.max_nondet_tree_depth)
Copy link
Contributor

Choose a reason for hiding this comment

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

So the depth is the minimal length of dereference-chain before null-pointer initialisation? And every chain longer than depth will have pointers initialised to null but only when they point to a struct that appeared somewhere before on this chain?

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, max_nondet_tree_depth gives the depth of a chain such that a pointer to a struct will be initialised to null if the depth of the chain exceeds it and the struct appeared already before somewhere on the chain. If there is no recursion the chains can have any depth.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. So it may turn out to be non-terminating but it would have nothing to do with this new code. I was just thinking if there is a more accurate way to describe the input option.

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 think if there's no recursion then the chains would always have finite length thus it can never be non-terminating. The current behaviour is similar to that of the java object factory.

@danpoe danpoe force-pushed the feature/nondet-init-structs branch 2 times, most recently from 3244d70 to 199bfd9 Compare November 2, 2018 11:54
@danpoe
Copy link
Contributor Author

danpoe commented Nov 23, 2018

@tautschnig @peterschrammel @thk123 This still requires code owner approval if you get a chance.

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: 9049aff).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92377593
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
Member

@peterschrammel peterschrammel left a comment

Choose a reason for hiding this comment

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

This is ready to go. @allredj confirmed that there is a passing bump.

@allredj
Copy link
Contributor

allredj commented Nov 23, 2018

@tautschnig tautschnig changed the title Recursive nondet init of pointers to structs Recursive nondet init of pointers to structs [blocks: #3443] Nov 24, 2018
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.

Some smaller requests remain, otherwise looks good. In future, I would really appreciate if such PRs could 1) be broken into several smaller PRs to make sure reviewing is also possible other than on weekends (where longer consecutive stretches of time may be available) and 2) each commit message has a body.

set(options);
}

virtual ~object_factory_parameterst()
Copy link
Collaborator

Choose a reason for hiding this comment

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

= default;

inline exprt get_nondet_bool(const typet &type)
inline exprt get_nondet_bool(
const typet &type,
const source_locationt &source_location = source_locationt())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not make this optional: there is a single call site (and the next commit adds a second one), which could trivially pass in a proper source location.

@@ -933,6 +934,10 @@ void cbmc_parse_optionst::help()
" --round-to-plus-inf rounding towards plus infinity\n"
" --round-to-minus-inf rounding towards minus infinity\n"
" --round-to-zero rounding towards zero\n"
" --max-nondet-tree-depth N limit size of nondet (e.g. input) object tree;\n" /* NOLINT(*) */ \
" at level N pointers are set to null\n" /* NOLINT(*) */ \
" --min-null-tree-depth N minimum level at which a pointer can first be\n" /* NOLINT(*) */ \
Copy link
Collaborator

Choose a reason for hiding this comment

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

This option is not added in the header file.

@@ -75,6 +77,7 @@ class optionst;
"(localize-faults)(localize-faults-method):" \
OPT_GOTO_TRACE \
OPT_VALIDATE \
"(max-nondet-tree-depth):" \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use OPT... instead of the raw string in here.

@@ -933,6 +934,10 @@ void cbmc_parse_optionst::help()
" --round-to-plus-inf rounding towards plus infinity\n"
" --round-to-minus-inf rounding towards minus infinity\n"
" --round-to-zero rounding towards zero\n"
" --max-nondet-tree-depth N limit size of nondet (e.g. input) object tree;\n" /* NOLINT(*) */ \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Define a HELP_... macro.

@@ -70,8 +70,7 @@ class languaget:public messaget
/// complete. Functions introduced here are visible to lazy loading and
/// can influence its decisions (e.g. picking the types of input parameters
/// and globals), whereas anything introduced during `final` cannot.
virtual bool generate_support_functions(
symbol_tablet &symbol_table)=0;
virtual bool generate_support_functions(symbol_tablet &symbol_table) = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whitespace change only?


class ansi_c_languaget:public languaget
{
public:
void set_language_options(const optionst &options) override
Copy link
Collaborator

Choose a reason for hiding this comment

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

Added but never invoked?

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 would e.g. be called by initialize_goto_model() where languaget & might reference ansi_c_languaget.

@@ -46,7 +46,7 @@ SCENARIO(
symbol_typet java_string_type("java::java.lang.String");
symbol_exprt expr("arg", java_string_type);

object_factory_parameterst object_factory_parameters;
java_object_factory_parameterst object_factory_parameters;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be merged into the earlier commit introducing java_object_factory_parameterst.

rm pointer-function-parameters-struct-non-recursive/test.desc
rm pointer-function-parameters-struct-simple-recursion/test.desc
rm pointer-function-parameters-struct-simple-recursion-2/test.desc
rm pointer-function-parameters-struct-simple-recursion-3/test.desc
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please merge into the commit introducing them.

CORE
main.c
--function func --min-null-tree-depth 10
^SIGNAL=0$
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add ^EXIT=10$

@tautschnig tautschnig assigned danpoe and unassigned tautschnig and kroening Nov 24, 2018
…rameters

This moves object_factory_parameterst to util, and creates a new class derived
from it called java_object_factory_parameterst in java_bytecode. This is to
separate out common object factory options in preparation of adding c object
factory parameters.
@danpoe danpoe force-pushed the feature/nondet-init-structs branch 2 times, most recently from 3fbc8e2 to be40ff5 Compare November 26, 2018 17:30
@danpoe danpoe force-pushed the feature/nondet-init-structs branch from be40ff5 to 0b605ea Compare November 26, 2018 17:41
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: 0b605ea).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92589920
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants