Skip to content
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

Fix GDA not visiting global operator delete #231

Merged
merged 1 commit into from
May 27, 2024
Merged

Conversation

DutChen18
Copy link
Member

When GlobalDepsAnalyzer encounters a function where isFreeFunctionName returns true, that function is not visited immediately. Instead, a flag is set indicating that a function named "free" should be visited later, if needed.

When isFreeFunctionName returns true for a function whose name is not "free" (so "_ZdlPv" or "_ZdaPv"), that function will never be visited by GDA. This results in a crash when the function references any other global that is deleted as a result of the function, and its children, not being visited.

Example of a program that would crash:

#include <cstdio>

void operator delete(void* ptr) noexcept {
        std::puts("test");
}

int main() {
        delete new int;
}

I don't see any point in defering visiting the global delete operators, so the solution is to simply replace the call to isFreeFunctionName so we only defer visiting the function named "free". Note that isFreeFunctionName is still used in other places where it should probably return true for the global delete operators as well.

When GlobalDepsAnalyzer encounters a function where `isFreeFunctionName`
returns true, that function is not visited immediately. Instead, a flag
is set indicating that a function named "free" should be visited later,
if needed.

When `isFreeFunctionName` returns true for a function whose name is not
"free" (so "_ZdlPv" or "_ZdaPv"), that function will never be visited by
GDA. This results in a crash when the function references any other
global that is deleted as a result of the function, and its children,
not being visited.

Example of a program that would crash:

```
#include <cstdio>

void operator delete(void* ptr) noexcept {
        std::puts("test");
}

int main() {
        delete new int;
}
```

I don't see any point in defering visiting the global delete operators,
so the solution is to simply replace the call to `isFreeFunctionName`
so we only defer visiting the function named "free". Note that
`isFreeFunctionName` is still used in other places where it should probably
return true for the global delete operators as well.
@DutChen18 DutChen18 requested a review from yuri91 May 27, 2024 10:26
@yuri91 yuri91 merged commit 0940c47 into master May 27, 2024
1 check passed
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.

2 participants