Skip to content

String preprocessing: don't re-initialise objects that already exist #3545

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

smowton
Copy link
Contributor

@smowton smowton commented Dec 7, 2018

Just set their length and data fields, leaving the others alone; otherwise it will overwrite any fields stored on java.lang.Object with their initialiser value.

This should not change any behaviour in cbmc / test-gen; it only has an effect when java.lang.Object has been augmented with extra fields, as we do to track taint, and I know the concurrency work has done to better model locks.

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.

Is it just me, or is is_constructor always set to true?

@@ -826,24 +826,37 @@ codet java_string_library_preprocesst::code_assign_components_to_java_string(
const exprt &lhs,
const exprt &rhs_array,
const exprt &rhs_length,
const symbol_table_baset &symbol_table)
const symbol_table_baset &symbol_table,
bool is_constructor)
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 update documentation

@@ -1083,14 +1097,14 @@ code_blockt java_string_library_preprocesst::make_init_function_from_call(
const java_method_typet &type,
const source_locationt &loc,
symbol_table_baset &symbol_table,
bool ignore_first_arg)
bool is_constructor)
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 update documentation

@@ -857,10 +870,11 @@ codet java_string_library_preprocesst::code_assign_components_to_java_string(
codet java_string_library_preprocesst::code_assign_string_expr_to_java_string(
const exprt &lhs,
const refined_string_exprt &rhs,
const symbol_table_baset &symbol_table)
const symbol_table_baset &symbol_table,
bool is_constructor)
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 update documentation

struct_rhs.copy_to_operands(rhs_array);
return code_assignt(
checked_dereference(lhs, lhs.type().subtype()), struct_rhs);
if(is_constructor)
Copy link
Contributor

Choose a reason for hiding this comment

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

Documenting the "why" would be useful.

@smowton smowton force-pushed the smowton/fix/string-refinement-dont-reinit-object branch from 8322911 to 655a788 Compare December 9, 2018 11:42
Just set their length and data fields, leaving the others alone; otherwise it will
overwrite taint fields, as well as lock fields and anything else introduced to
java.lang.Object.
@smowton smowton force-pushed the smowton/fix/string-refinement-dont-reinit-object branch from 655a788 to e6fca9b Compare December 10, 2018 13:19
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: e6fca9b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/94196111

@smowton
Copy link
Contributor Author

smowton commented Dec 11, 2018

@allredj take a look at ignore_first_arg which is renamed to is_constructor. I've added docs; please re-review

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.

LGTM

@smowton smowton merged commit e1ecf26 into diffblue:develop Dec 12, 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.

3 participants