Skip to content

add parameter for depth of recursive objects #567

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

Closed

Conversation

mgudemann
Copy link
Contributor

The original implementation could enter an infinite loop for recursive objects,
this patch adds a maximal recursion depth to prevent this and at the same time
to allow for having non-null object members.

fixes #561

@mgudemann mgudemann force-pushed the fix_infinite_object_recursion branch from 2ad3479 to 0c8aded Compare February 22, 2017 15:58
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.

I'm not convinced this is the correct algorithm. The commit message should mention that this fixes #561.

@@ -1153,6 +1153,8 @@ void cbmc_parse_optionst::help()
" --classpath dir/jar set the classpath\n"
" --main-class class-name set the name of the main class\n"
// NOLINTNEXTLINE(whitespace/line_length)
"--java-max-recursion-depth max recursion depth for nondet init of recursive objects\n"
Copy link
Collaborator

Choose a reason for hiding this comment

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

While I do accept that the initialisation code currently exists for Java only: I don't think this command-line option should remain as specific. Furthermore the option name suggests that functional recursion is limited, whereas this is all about object initialisation. How about: "recursive-object-bound"?


return;
if(recursion_depth<max_recursion_depth)
recursion_depth++;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't this going to count the total number of recursive steps, across multiple "branches" of the data structures? For instance, for mutual recursion, the number of objects of a type X would actually just be max_recursion_depth/2.

Copy link
Member

Choose a reason for hiding this comment

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

@mgudemann, what is the intended semantics of the parameter? I agree with @tautschnig that the current solution is rather unintuitive from the user's perspective.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a problem with null initialization of objects. In the original implementation, a recursion set was used that would in an object hierarchy prevent instantiation of object types already seen. There were cases where this was problematic, if an object contained a recursive instantation, effectively this lead to a null value and due to various options (--assertions-as-assumptions etc.) created an ASSUME non null for that exact member, leading to inconsistent model.

The idea of this parameter was to create a solution between using exclusively the recursion set and not using it at all, i.e., having a bounded initialization of hierarchical objects.

Copy link
Collaborator

@tautschnig tautschnig Mar 21, 2017

Choose a reason for hiding this comment

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

Shouldn't the solution be passing the recursion_depth as a parameter? Decrement (or increment) it on each recursive call, and check for 0 (respectively a chosen maximum). Yes, you need the recursion set to detect the fact that you are doing a recursive step, but counters need to be branch-specific, not global across the structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are perfectly right with this

The original implementation could enter an infinite loop for recursive objects,
this patch adds a maximal recursion depth to prevent this and at the same time
to allow for having non-null object members.
@mgudemann mgudemann force-pushed the fix_infinite_object_recursion branch from 0c8aded to 259c59d Compare March 14, 2017 09:48
@mgudemann
Copy link
Contributor Author

done in #824

@mgudemann mgudemann closed this May 15, 2017
NathanJPhillips added a commit to NathanJPhillips/cbmc that referenced this pull request Sep 6, 2018
…ng-base

Don't add bases that aren't defined in the trace file
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.

3 participants