Skip to content

C++: Call qualifiers are passed by reference #3439

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 1 commit into from
May 12, 2020

Conversation

jbj
Copy link
Contributor

@jbj jbj commented May 11, 2020

After #3382 changed the escape analysis to model qualifiers as escaping, there was an imbalance in the SSA library, where addressTakenVariable excludes variables from SSA analysis if they have their address taken but are not passed by reference. This showed up as a missing result in TOCTOUFilesystemRace.ql, demonstrated with a test case in #3432.

This PR changes the definition of "pass by reference" to include call qualifiers, which allows SSA modeling of variables that have member function calls on them.

After github#3382 changed the escape analysis to model qualifiers as escaping,
there was an imbalance in the SSA library, where `addressTakenVariable`
excludes variables from SSA analysis if they have their address taken
but are _not_ passed by reference. This showed up as a missing result in
`TOCTOUFilesystemRace.ql`, demonstrated with a test case in github#3432.

This commit changes the definition of "pass by reference" to include
call qualifiers, which allows SSA modeling of variables that have member
function calls on them.
@jbj jbj added the C++ label May 11, 2020
@jbj jbj requested a review from geoffw0 May 11, 2020 07:49
@jbj jbj requested a review from a team as a code owner May 11, 2020 07:49
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!

@jbj
Copy link
Contributor Author

jbj commented May 11, 2020

Here is the SSA code that was out of balance:

va.isAddressOfAccessNonConst() and
// If the address is passed to a function then we will trust that it
// is only used to modify the variable for the duration of the
// function call.
not exists(Call call | call.passesByReferenceNonConst(_, va))

@jbj
Copy link
Contributor Author

jbj commented May 11, 2020

Started https://jenkins.internal.semmle.com/job/Changes/job/CPP-Differences/1115/

@jbj
Copy link
Contributor Author

jbj commented May 12, 2020

The CPP-Differences job has finished, and it reports exactly one difference: the restoration of the result that got lost after #3382.

@MathiasVP MathiasVP merged commit 73882c9 into github:master May 12, 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.

2 participants