Skip to content

Use symbol_tablet::lookup_ref and ::get_writeable_ref #4437

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

smowton
Copy link
Contributor

@smowton smowton commented Mar 26, 2019

These all replace uses of lookup and get_writeable that were immediately dereferenced without
being checked, thereby replacing any possible failure due to reading through a null pointer with
an invariant failure.

These all replace uses of lookup and get_writeable that were immediately dereferenced without
being checked, thereby replacing any possible failure due to reading through a null pointer with
an invariant failure.
Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

This seems like a worth-while thing to do and the changes to my area are fine BUT could we make this simpler and more stringent? Are there any legitimate uses of get_writeable where it is null? Couldn't this become an invariant in general? Likewise what exactly are the invariants on lookup?

@smowton
Copy link
Contributor Author

smowton commented Mar 26, 2019

Users of get_writeable:
src/jsil/jsil_typecheck.cpp: to throw rather than raise an invariant
src/goto-cc/linker_script_merge.cpp: to skip undefined symbols
src/cpp/cpp_typecheck_template.cpp: to replace / consistency-check repeated template definitions
src/cpp/cpp_declarator_converter.cpp: to retry with an adjusted name on failure

So there aren't many users but they do exist. Unsure what you're asking about lookup, which is a plain old search function.

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.

Thank you!!!

@@ -227,7 +227,7 @@ void acceleration_utilst::stash_variables(
it!=vars.end();
++it)
{
symbolt orig=*symbol_table.lookup(*it);
symbolt orig = symbol_table.lookup_ref(*it);
Copy link
Collaborator

Choose a reason for hiding this comment

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

const symbolt &orig

@@ -768,7 +768,7 @@ void polynomial_acceleratort::stash_variables(
it!=vars.end();
++it)
{
symbolt orig=*symbol_table.lookup(*it);
symbolt orig = symbol_table.lookup_ref(*it);
Copy link
Collaborator

Choose a reason for hiding this comment

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

const symbolt &orig

These were never changed, so might as well hold a reference into the symbol table.
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: b79a100).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105870484
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.

@tautschnig tautschnig merged commit 811a601 into diffblue:develop Mar 26, 2019
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: 78c1c31).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105877346
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.

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.

5 participants