r207031 - Fix leak introduced in r194610, found by LSan.
Sergey Matveev
earthdok at google.com
Thu Apr 24 03:26:28 PDT 2014
On Thu, Apr 24, 2014 at 3:06 AM, Nico Weber <thakis at chromium.org> wrote:
> On Wed, Apr 23, 2014 at 3:51 PM, Sergey Matveev <earthdok at google.com>wrote:
>
>>
>>
>>
>> On Thu, Apr 24, 2014 at 1:41 AM, Nico Weber <nicolasweber at gmx.de> wrote:
>>
>>> Author: nico
>>> Date: Wed Apr 23 16:41:51 2014
>>> New Revision: 207031
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=207031&view=rev
>>> Log:
>>> Fix leak introduced in r194610, found by LSan.
>>>
>>> LSan folks: LSan pointed to
>>> #0 0x4953e0 in operator new[](unsigned long)
>>> llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:64
>>> #1 0x7fb82af5372f in clang::RewriteRope::MakeRopeString(char const*,
>>> char const*) llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:796
>>> instead of to the actual leak, which made tracking this down slower than
>>> it could have been.
>>>
>> Was it missing part of the stack between MakeRopeString() and
>> convertCommentToXML()?
>>
>
> It said
>
> #0 0x4953e0 in operator new[](unsigned long)
> llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:64
> #1 0x7f731fce472f in clang::RewriteRope::MakeRopeString(char const*,
> char const*) llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:796
> #2 0x7f731fce79e1 in assign
> llvm/tools/clang/include/clang/Rewrite/Core/RewriteRope.h:222
> #3 0x7f731fce79e1 in operator->
> llvm/tools/clang/include/clang/Rewrite/Core/Rewriter.h:97
> #4 0x7f731fce79e1 in clang::Rewriter::getEditBuffer
> llvm/tools/clang/lib/Rewrite/Core/Rewriter.cpp:235
> #5 0x7f731e687d41 in getRewrittenText
> llvm/tools/clang/lib/Index/SimpleFormatContext.h:62
> #6 0x7f731e687d41 in formatTextOfDeclaration
> llvm/tools/clang/lib/Index/CommentToXML.cpp:621
> #7 0x7f731e687d41 in (anonymous
> namespace)::CommentASTToXMLConverter::visitFullComment
> llvm/tools/clang/lib/Index/CommentToXML.cpp:959
> #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
> #9 0x7f731e6819f3 in
> clang::index::CommentToXMLConverter::convertCommentToXML
> llvm/tools/clang/lib/Index/CommentToXML.cpp:1170
>
> 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.
>
If the SimpleFormatContext was also being leaked, then there must have been
another stack trace in the report pointing to it.
>
>
>>
>>> Modified:
>>> cfe/trunk/include/clang/Index/CommentToXML.h
>>> cfe/trunk/lib/Index/CommentToXML.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Index/CommentToXML.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/CommentToXML.h?rev=207031&r1=207030&r2=207031&view=diff
>>>
>>> ==============================================================================
>>> --- cfe/trunk/include/clang/Index/CommentToXML.h (original)
>>> +++ cfe/trunk/include/clang/Index/CommentToXML.h Wed Apr 23 16:41:51 2014
>>> @@ -29,6 +29,7 @@ class CommentToXMLConverter {
>>>
>>> public:
>>> CommentToXMLConverter() : FormatContext(0), FormatInMemoryUniqueId(0)
>>> {}
>>> + ~CommentToXMLConverter();
>>>
>>> void convertCommentToHTML(const comments::FullComment *FC,
>>> SmallVectorImpl<char> &HTML,
>>>
>>> Modified: cfe/trunk/lib/Index/CommentToXML.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=207031&r1=207030&r2=207031&view=diff
>>>
>>> ==============================================================================
>>> --- cfe/trunk/lib/Index/CommentToXML.cpp (original)
>>> +++ cfe/trunk/lib/Index/CommentToXML.cpp Wed Apr 23 16:41:51 2014
>>> @@ -1136,6 +1136,10 @@ void CommentASTToXMLConverter::appendToR
>>> Result << "]]>";
>>> }
>>>
>>> +CommentToXMLConverter::~CommentToXMLConverter() {
>>> + delete FormatContext;
>>> +}
>>> +
>>> void CommentToXMLConverter::convertCommentToHTML(const FullComment *FC,
>>> SmallVectorImpl<char>
>>> &HTML,
>>> const ASTContext
>>> &Context) {
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>>
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140424/a6fef9d4/attachment.html>
More information about the cfe-commits
mailing list