Skip to content

C++/C#: Fix invalid overlap #3112

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 4 commits into from
Mar 25, 2020

Conversation

dbartol
Copy link

@dbartol dbartol commented Mar 23, 2020

Fixes https://github.com/github/codeql-c-analysis-team/issues/34

Instruction.getDefinitionOverlap() depends on SSAConstruction::getMemoryOperandDefinition(), which in turn depends on SSAConstruction::hasMemoryOperandDefinition(). When the definition in question came from a Chi instruction, hasMemoryOperandDefinition() incorrectly bound overlap to the overlap relationship between the original (non-Chi) instruction and the use. The fix is to make use of the actualDefLocation parameter to getDefinitionOrChiInstruction(), which specifies the location for the result of the Chi in that case.

This PR is easier to review commit-by-commit, so that you can see the new sanity test introduced, along with the original failures it revealed.

Dave Bartolomeo added 2 commits March 23, 2020 14:37
…p()`

The result of `getDefinitionOverlap()` should never be `MayPartiallyOverlap`, because if that were the case, we should have inserted as `Chi` instruction and hooked the definition up to that instead.

There are quite a few existing failures.
`Instruction.getDefinitionOverlap()` depends on `SSAConstruction::getMemoryOperandDefinition()`, which in turn depends on `SSAConstruction::hasMemoryOperandDefinition()`. When the definition in question came from a `Chi` instruction, `hasMemoryOperandDefinition()` incorrectly bound `overlap` to the overlap relationship between the original (non-`Chi`) instruction and the use. The fix is to make use of the `actualDefLocation` parameter to `getDefinitionOrChiInstruction()`, which specifies the location for the result of the `Chi` in that case.
@dbartol dbartol added the C++ label Mar 23, 2020
@dbartol dbartol requested review from jbj and MathiasVP March 23, 2020 19:00
@dbartol dbartol requested review from a team as code owners March 23, 2020 19:00
Copy link
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

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

What a delightfully simple fix! I just have one comment attached below.

All changes look like real improvements.
@dbartol dbartol added the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label Mar 24, 2020
@dbartol
Copy link
Author

dbartol commented Mar 24, 2020

The only remaining failures are the three SAMATE test failures from the internal repo. I've opened a separate PR there to fix those failures.

Copy link
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

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

LGTM

@MathiasVP MathiasVP merged commit ae076da into github:master Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ depends on internal PR This PR should only be merged in sync with an internal Semmle PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants