Skip to content

[TG-9189] Value retriever: Allow @nondetLength field to be false. #5043

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 1 commit into from
Aug 27, 2019

Conversation

allredj
Copy link
Contributor

@allredj allredj commented Aug 20, 2019

This can happen with Arrays$ArrayList.
get_untyped now no longer calls has_nondet_length, which would fail if @nondetLength was false.

There will be a regression test in TG.

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

@allredj allredj self-assigned this Aug 20, 2019
@allredj allredj changed the title Value retriever: Allow @nondetLength field to be false. Value retriever: Allow @nondetLength field to be false. [TG-9189] Aug 20, 2019
Copy link
Contributor Author

@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: 3786fa1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/123942200
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.

@codecov-io
Copy link

Codecov Report

Merging #5043 into develop will decrease coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5043      +/-   ##
===========================================
- Coverage    69.53%   69.48%   -0.06%     
===========================================
  Files         1314     1310       -4     
  Lines       108988   108815     -173     
===========================================
- Hits         75786    75611     -175     
- Misses       33202    33204       +2
Impacted Files Coverage Δ
jbmc/src/java_bytecode/assignments_from_json.cpp 97.8% <100%> (+0.01%) ⬆️
...lvers/strings/string_constraint_generator_main.cpp 80.72% <0%> (-2.61%) ⬇️
src/util/unicode.cpp 78.07% <0%> (-0.75%) ⬇️
jbmc/src/java_bytecode/expr2java.cpp 84.57% <0%> (-0.4%) ⬇️
.../goto-instrument/goto_instrument_parse_options.cpp 56.26% <0%> (-0.4%) ⬇️
src/solvers/strings/string_refinement.cpp 88.28% <0%> (-0.25%) ⬇️
src/solvers/strings/string_dependencies.cpp 82.6% <0%> (-0.15%) ⬇️
unit/catch/catch.hpp 41.26% <0%> (-0.09%) ⬇️
src/goto-symex/goto_symex.cpp 99.34% <0%> (-0.01%) ⬇️
...src/java_bytecode/java_bytecode_convert_method.cpp 97.52% <0%> (ø) ⬆️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 153a4b9...3786fa1. Read the comment docs.

if(get_type(json) || has_nondet_length(json))
return json[object_key];
return json;
if(!json.is_object())
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you really expecting just any old thing here when it's not an object, or do you expect something specific, such as null for example? If so, check for your expectation.

Copy link
Contributor

Choose a reason for hiding this comment

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

@smowton It could be pretty much anything so I think this change makes sense.

Copy link
Contributor

@antlechner antlechner 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 the ticket number should be at the beginning of the PR title.
Thanks for fixing this!

if(get_type(json) || has_nondet_length(json))
return json[object_key];
return json;
if(!json.is_object())
Copy link
Contributor

Choose a reason for hiding this comment

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

@smowton It could be pretty much anything so I think this change makes sense.


const auto &json_object = to_json_object(json);
PRECONDITION(
get_type(json) || json_object.find("@nondetLength") != json_object.end());
Copy link
Contributor

@antlechner antlechner Aug 21, 2019

Choose a reason for hiding this comment

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

⛏️ We could be more precise and assert the current precondition only if json is contains a json_arrayt, and assert only get_type(json) otherwise, as we wouldn't expect a @nondetLength key on e.g. a number or boolean. But then again in the current version we would just ignore such @nondetLength keys, which wouldn't cause any harm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

precondition is split

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 introduced problems, so I reverted to the initial solution.

@antlechner antlechner added the Needs TG approval 🦉 Only merge with explicit approval from test-gen maintainers label Aug 21, 2019
@allredj allredj force-pushed the bugfix/retriever-arrays-arraylist branch 2 times, most recently from 01d759f to 31f77ab Compare August 21, 2019 13:21
Copy link
Contributor Author

@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: 01d759f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/124064989
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.

Copy link
Contributor Author

@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: 31f77ab).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/124068722


const auto &json_object = to_json_object(json);
if(json.is_array())
PRECONDITION(json_object.find("@nondetLength") != json_object.end());
Copy link
Contributor

Choose a reason for hiding this comment

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

This would have to be

PRECONDITION(get_type(json) || json_object.find("@nondetLength") != json_object.end());

@allredj allredj force-pushed the bugfix/retriever-arrays-arraylist branch from 31f77ab to 926d4b8 Compare August 21, 2019 17:22
Copy link
Contributor Author

@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: 926d4b8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/124113599
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.

@allredj allredj force-pushed the bugfix/retriever-arrays-arraylist branch 2 times, most recently from 43b05de to 681f353 Compare August 22, 2019 14:24
@allredj
Copy link
Contributor Author

allredj commented Aug 22, 2019

Blocked by #5047

This can happen with Arrays$ArrayList.
get_untyped now no longer calls has_nondet_length, which would fail if
@nondetLength was false.
@allredj allredj force-pushed the bugfix/retriever-arrays-arraylist branch from 681f353 to 901403d Compare August 27, 2019 09:33
@allredj allredj changed the title Value retriever: Allow @nondetLength field to be false. [TG-9189] [TG-9189] Value retriever: Allow @nondetLength field to be false. Aug 27, 2019
Copy link
Contributor Author

@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: 901403d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/124729691

@allredj allredj removed the Needs TG approval 🦉 Only merge with explicit approval from test-gen maintainers label Aug 27, 2019
@allredj allredj merged commit 8f06fdf into develop Aug 27, 2019
@allredj allredj deleted the bugfix/retriever-arrays-arraylist branch August 27, 2019 17:06
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.

4 participants