Skip to content

Temporary stack variable being stored as the wrong type #3224

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

JohnDumbell
Copy link
Contributor

@JohnDumbell JohnDumbell commented Oct 23, 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).
  • 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.

In a very particular instance (shown in the unit test) the type of the temporary stack variable got changed from what it was originally to the type of whatever expression triggered the save_stack_entries call. This just makes sure the type of the stored variable doesn't change.

@JohnDumbell JohnDumbell force-pushed the jd/bugfix/temp_variable_type_wrong branch 2 times, most recently from 05180a8 to 7bbedf6 Compare October 24, 2018 09:23
CORE
Primary.class
--function stuff.array_issue.Primary.Run
^VERIFICATION SUCCESSFUL|VERIFICATION FAILED$
Copy link
Contributor

Choose a reason for hiding this comment

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

We really don't know which one to expect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't really mind, as long as it completes in some form the fix will still be in place (it just exceptioned half way through before).

Copy link
Contributor

Choose a reason for hiding this comment

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

True, but generally we should know what our tests are doing and specify that. In this case I recommend putting an assert(false) in the Accept method and checking that we have VERIFICATION FAILED and also that we failed that particular assertion, thus establishing that the test explored the path where we make the call (cf. failing an earlier null-pointer check or something) as we intended.

@@ -3241,7 +3241,8 @@ void java_bytecode_convert_methodt::save_stack_entries(
}
if(replace)
{
create_stack_tmp_var(tmp_var_prefix, tmp_var_type, block, stack_entry);
create_stack_tmp_var(
Copy link
Contributor

Choose a reason for hiding this comment

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

No functional changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Style commit I just pushed got rid of the change for some reason - fixed now.

In certain situations the stack of tmp_var's had the wrong type associated with it, as each replacement entry was being created with the type of the expression it was built from. In this particular case a java array created and directly passed into a method was causing the 'this' temp variable to be stored as the type of the array itself, causing an assertion error further on.

The type of code causing this error:

this.objectInstance.Method(new int[]{0, 1, 2});
@JohnDumbell JohnDumbell force-pushed the jd/bugfix/temp_variable_type_wrong branch from 7bbedf6 to 0bb165d Compare October 24, 2018 09:33
Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Fine with me once the test is firmed up as noted above

@JohnDumbell JohnDumbell force-pushed the jd/bugfix/temp_variable_type_wrong branch from 0bb165d to 29d81de Compare October 24, 2018 10:12
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: 0bb165d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88978662
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.

@JohnDumbell JohnDumbell force-pushed the jd/bugfix/temp_variable_type_wrong branch from 29d81de to b9392c5 Compare October 24, 2018 10: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.

Passed Diffblue compatibility checks (cbmc commit: b9392c5).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88986777

@smowton smowton merged commit 8a398ee into diffblue:develop Oct 29, 2018
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