-
Notifications
You must be signed in to change notification settings - Fork 750
UB fix: new-delete-type-mismatch in ~CodeGenTypes() #7348
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
base: main
Are you sure you want to change the base?
Conversation
It is undefined behavior to use `delete` expression on something which was not created with corresponding `new` expression. Switching to explicit global `operator delete()` call to match with `operator new()` call at `CGFunctionInfo::create()`. This issue is raised by Chromium ClusterFuzz, with ASan enabled. https://crbug.com/410141973
Note that Mikihito also created a similar PR in LLVM: llvm/llvm-project#135787 |
I noticed that for Windows builds, the option for sized deallocations was explicitly disabled here, and AFAICT, this is a DXC-specific change. The equivalent flag is not disabled for Clang/GCC ( In any case, I think we will likely drop this PR because there are other |
I modified As I believe |
@@ -47,7 +47,7 @@ CodeGenTypes::~CodeGenTypes() { | |||
|
|||
for (llvm::FoldingSet<CGFunctionInfo>::iterator | |||
I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; ) | |||
delete &*I++; | |||
::operator delete(&*I++); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents calling the destructor, which is maybe working because the destructors are trivial, but we probably shouldn't rely on that.
It is undefined behavior to use
delete
expression on something which was not created with correspondingnew
expression. Switching to explicit globaloperator delete()
call to match withoperator new()
call atCGFunctionInfo::create()
.This issue is raised by Chromium ClusterFuzz, with ASan enabled. https://crbug.com/410141973