<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 24, 2014 at 3:06 AM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="">On Wed, Apr 23, 2014 at 3:51 PM, Sergey Matveev <span dir="ltr"><<a href="mailto:earthdok@google.com" target="_blank">earthdok@google.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">

<div>On Thu, Apr 24, 2014 at 1:41 AM, Nico Weber <span dir="ltr"><<a href="mailto:nicolasweber@gmx.de" target="_blank">nicolasweber@gmx.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: nico<br>
Date: Wed Apr 23 16:41:51 2014<br>
New Revision: 207031<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=207031&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=207031&view=rev</a><br>
Log:<br>
Fix leak introduced in r194610, found by LSan.<br>
<br>
LSan folks: LSan pointed to<br>
    #0 0x4953e0 in operator new[](unsigned long) llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:64<br>
    #1 0x7fb82af5372f in clang::RewriteRope::MakeRopeString(char const*, char const*) llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:796<br>
instead of to the actual leak, which made tracking this down slower than<br>
it could have been.<br></blockquote></div><div>Was it missing part of the stack between MakeRopeString() and convertCommentToXML()?</div></div></div></div></blockquote><div><br></div></div><div>It said</div><div><br></div>
<div><div class="">
<div>    #0 0x4953e0 in operator new[](unsigned long) llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:64</div></div><div>    #1 0x7f731fce472f in clang::RewriteRope::MakeRopeString(char const*, char const*) llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:796</div>

<div>    #2 0x7f731fce79e1 in assign llvm/tools/clang/include/clang/Rewrite/Core/RewriteRope.h:222</div><div>    #3 0x7f731fce79e1 in operator-> llvm/tools/clang/include/clang/Rewrite/Core/Rewriter.h:97</div><div>    #4 0x7f731fce79e1 in clang::Rewriter::getEditBuffer llvm/tools/clang/lib/Rewrite/Core/Rewriter.cpp:235</div>

<div>    #5 0x7f731e687d41 in getRewrittenText llvm/tools/clang/lib/Index/SimpleFormatContext.h:62</div><div>    #6 0x7f731e687d41 in formatTextOfDeclaration llvm/tools/clang/lib/Index/CommentToXML.cpp:621</div><div>    #7 0x7f731e687d41 in (anonymous namespace)::CommentASTToXMLConverter::visitFullComment llvm/tools/clang/lib/Index/CommentToXML.cpp:959</div>

<div>    #8 0x7f731e682987 in clang::comments::CommentVisitorBase<clang::comments::make_const_ptr, (anonymous namespace)::CommentASTToXMLConverter, void>::visit asan-boot/stage2/tools/clang/include/clang/AST/CommentNodes.inc:69</div>

<div>    #9 0x7f731e6819f3 in clang::index::CommentToXMLConverter::convertCommentToXML llvm/tools/clang/lib/Index/CommentToXML.cpp:1170</div></div><div><br></div><div>or similar. Pointing to the "FormatContext = new SimpleFormatContext" would've been easier for me to understand, as that's the object that kept the rope alive.</div>
</div></div></div></blockquote><div>If the SimpleFormatContext was also being leaked, then there must have been another stack trace in the report pointing to it.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">

<div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
Modified:<br>
    cfe/trunk/include/clang/Index/CommentToXML.h<br>
    cfe/trunk/lib/Index/CommentToXML.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Index/CommentToXML.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/CommentToXML.h?rev=207031&r1=207030&r2=207031&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/CommentToXML.h?rev=207031&r1=207030&r2=207031&view=diff</a><br>



==============================================================================<br>
--- cfe/trunk/include/clang/Index/CommentToXML.h (original)<br>
+++ cfe/trunk/include/clang/Index/CommentToXML.h Wed Apr 23 16:41:51 2014<br>
@@ -29,6 +29,7 @@ class CommentToXMLConverter {<br>
<br>
 public:<br>
   CommentToXMLConverter() : FormatContext(0), FormatInMemoryUniqueId(0) {}<br>
+  ~CommentToXMLConverter();<br>
<br>
   void convertCommentToHTML(const comments::FullComment *FC,<br>
                             SmallVectorImpl<char> &HTML,<br>
<br>
Modified: cfe/trunk/lib/Index/CommentToXML.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=207031&r1=207030&r2=207031&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=207031&r1=207030&r2=207031&view=diff</a><br>



==============================================================================<br>
--- cfe/trunk/lib/Index/CommentToXML.cpp (original)<br>
+++ cfe/trunk/lib/Index/CommentToXML.cpp Wed Apr 23 16:41:51 2014<br>
@@ -1136,6 +1136,10 @@ void CommentASTToXMLConverter::appendToR<br>
   Result << "]]>";<br>
 }<br>
<br>
+CommentToXMLConverter::~CommentToXMLConverter() {<br>
+  delete FormatContext;<br>
+}<br>
+<br>
 void CommentToXMLConverter::convertCommentToHTML(const FullComment *FC,<br>
                                                  SmallVectorImpl<char> &HTML,<br>
                                                  const ASTContext &Context) {<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>