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
Use-after-free in FunctionSpecializationPass #52821
Comments
Thanks for the report and also for copying me in. |
Turning the instance variable named "Condition" of the class |
This is a fix for a use-after-free found by the address sanitizer when compiling GCC: #52821 The Function Specialization pass may remove instructions, cached inside the PredicateBase class, which are later being dereferenced from the SCCPInstVisitor class. To prevent the dangling references I am lazily deleting the dead instructions after the Solver has run. Differential Revision: https://reviews.llvm.org/D118591
The sanitizer build https://lab.llvm.org/buildbot/#/builders/168/builds/4555 succeeded. I am closing this issue. |
This is a fix for a use-after-free found by the address sanitizer when compiling GCC: llvm/llvm-project#52821 The Function Specialization pass may remove instructions, cached inside the PredicateBase class, which are later being dereferenced from the SCCPInstVisitor class. To prevent the dangling references I am lazily deleting the dead instructions after the Solver has run. Differential Revision: https://reviews.llvm.org/D118591
There is a use-after-free issue in FunctionSpecializationPass. In
tryToReplaceWithConstant
, After the replacement has happened, the code deletes the newly-replaced instruction. However, dangling pointers to the deleted instruction remain inSCCPInstVisitor::AnalysisResults
.AnalysisResults
is a map fromFunction *
to the results of various analysis passes. AsFunctionSpecializationPass
continues to run, it may attempt to dereference this dangling pointer. The result of this is a very rare segfault.If compiling opt with address sanitizer, asan will catch the use-after-free. I've attached a reduced (but unfortunately still huge) bitcode test case that, when opt is compiled to use asan, will reproduce the issue. This bitcode reproduces the use-after-free as-of commit
55c71c9eac9bc7f956a05fa9258fad4f86565450
. I used bugpoint to reduce this test case, and while the original case reproduces the issue in both my downstream, and upstream opt, the reduced test case no longer reproduces the issue in my downstream. I'll upload the original test case if the reduced case does not reproduce the issue. I will also attach the output of asan on my machine.PLEASE NOTE: This test case is derived from compiling GCC. This code should not be the basis for any test case that is committed to the project as it will be a GPL violation.
asan_dump.txt
bugpoint reduced.zip
original case.zip
The text was updated successfully, but these errors were encountered: