Hi Chandler,<br><br>Thanks for the feedback...<br><br><div class="gmail_quote">On Sat, Dec 1, 2012 at 5:14 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div dir="ltr">Zhou, this patch was never removed. Please do not commit patches without review first. Please revert and ping the review thread.</div>


</div></blockquote><div><br>Done. Will never check in before approval.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif;font-size:10pt">


<div dir="ltr"><div><br>
</div><div>While it might seem like this patch is "obvious" two things make it clear that it is not:</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 25, 2012 at 9:45 PM, Zhou Sheng <span dir="ltr"><<a href="mailto:zhousheng00@gmail.com" target="_blank">zhousheng00@gmail.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: sheng<br>
Date: Sun Nov 25 23:45:53 2012<br>
New Revision: 168581<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=168581&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=168581&view=rev</a><br>
Log:<br>
Fix a PassManager pointer use-after-free bug.<br>
The bug can be triggered when we require LoopInfo analysis ahead of DominatorTree construction in a Module Pass.</blockquote><div><br></div><div>Then you should include a test case which demonstrates the bug under valgrind, or some other use-after-free detection system.</div>


</div></div></div></div></blockquote><div><br>I already have a case to repeat the issue, and attached it with the patch in the email I sent to llvm-commit for code review a week ago. But I'm not sure how to add this case to llvm test suit as the case itself is a ModulePass sample which needs to compile with llvm. Any suggestion?<br>


 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">



<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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.<br>



</blockquote><div><br></div><div>"somehow" isn't a good enough explanation for this fix being the correct fix. You need to actually understand the complete issue. Also, the comments below don't really seem to match your description here.</div>


</div></div></div></div></blockquote><div><br>Okay, how about this:  " However, the freed pointer is still passed to FunctionPassManagerImpl::setLastUser() for accessing, and then results in crash"<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div><br></div><div><br></div><div>Anyways, we should take the rest of this to the code review thread, and continue there until the review is complete before committing.</div></div></div></div></div></blockquote><div><br>


Okay, got it. <br><br>-Sheng<br></div></div><br>