Skip to content

C++: Fix MemoryLocation with multiple VirtualVariables#3577

Merged
MathiasVP merged 3 commits into
github:masterfrom
dbartol:github/codeql-c-analysis-team/69
May 29, 2020
Merged

C++: Fix MemoryLocation with multiple VirtualVariables#3577
MathiasVP merged 3 commits into
github:masterfrom
dbartol:github/codeql-c-analysis-team/69

Conversation

@dbartol

@dbartol dbartol commented May 27, 2020

Copy link
Copy Markdown

While investigating a bug with TInstruction sharing, I discovered that we had a case where alias analysis could create two VirtualVariables for the same Allocation. For an indirect parameter allocation, we were using the type of the pointer variable as the type of the indirect allocation, instead of just Unknown. If the IRType of the pointer variable was the same type as the type of at least one access to the indirect allocation, we'd create both an EntireAllocationVirtualVariable and a VariableVirtualVariable for the allocation.

I added a new consistency test to guard against this in the future. This also turned out to be the root cause of the one existing known consistency failure in the IR tests.

While investigating a bug with `TInstruction` sharing, I discovered that we had a case where alias analysis could create two `VirtualVariable`s for the same `Allocation`. For an indirect parameter allocation, we were using the type of the pointer variable as the type of the indirect allocation, instead of just `Unknown`. If the `IRType` of the pointer variable was the same type as the type of at least one access to the indirect allocation, we'd create both an `EntireAllocationVirtualVariable` and a `VariableVirtualVariable` for the allocation.

I added a new consistency test to guard against this in the future. This also turned out to be the root cause of the one existing known consistency failure in the IR tests.
@dbartol dbartol added the C++ label May 27, 2020
@dbartol dbartol requested review from a team as code owners May 27, 2020 18:07

@MathiasVP MathiasVP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! (apart from the failing testcase that needs to be accepted)

@rdmarsh2

Copy link
Copy Markdown
Contributor

Looks like this conflicts with #3571 (which added a consistency failure that I think this will resolve).

@dbartol

dbartol commented May 29, 2020

Copy link
Copy Markdown
Author

Yup, that’s exactly what happened. I’ve merged and it’s all good now.

@MathiasVP MathiasVP merged commit a305d39 into github:master May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants