[llvm-commits] [PATCH] Fix a PassManager pointer use-after-free bug (Sheng Zhou)

Sheng Zhou zhousheng00 at gmail.com
Wed Nov 21 22:00:21 PST 2012


Hi All,

The attached patch fixes a PassManager pointer use-after-free bug. Please
kindly let me know if the patch is good to commit.
The bug can be triggered when we require LoopInfo analysis ahead of
DominatorTree construction in a Module Pass.
The cause is that the LoopInfo analysis itself also invokes DominatorTree
construction, therefore, when PassManager schedules LoopInfo, it will add
DominatorTree first.
Then after that, when the PassManger turns to schedule DominatorTree
invoked by the above ModulePass, it finds there is already a DominatorTree,
so it delete the redundant one.
However, somehow it still try to access that pass pointer after free as
code pasted below, which results in segment fault.

Also attached the test case to repeat the issue.


Thanks,
Sheng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121122/1f875c90/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pm.patch
Type: application/octet-stream
Size: 778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121122/1f875c90/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestPass.cpp
Type: text/x-c++src
Size: 862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121122/1f875c90/attachment.cpp>


More information about the llvm-commits mailing list