[LLVMbugs] [Bug 19689] New: Parser::ParseParameterDeclarationClause leaks memory

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 8 11:54:45 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19689

            Bug ID: 19689
           Summary: Parser::ParseParameterDeclarationClause leaks memory
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

LSan reports:

Script:
--
/usr/local/google/ssd/asan-boot/stage2/./bin/clang -cc1 -internal-isystem
/usr/local/google/ssd/asan-boot/stage2/bin/../lib/clang/3.5.0/include
-std=c++11 -verify
/home/kcc/llvm/tools/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp
--
Exit Code: 23

Command Output (stderr):
--

=================================================================
==26235==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x7c0140 in operator new(unsigned long)
/home/kcc/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:62
    #1 0x44e56e9 in
clang::Parser::ParseParameterDeclarationClause(clang::Declarator&,
clang::ParsedAttributes&,
llvm::SmallVectorImpl<clang::DeclaratorChunk::ParamInfo>&,
clang::SourceLocation&) /home/kcc/llvm/tools/clang/lib/Parse/ParseDecl.cpp:5381
    #2 0x44dd719 in clang::Parser::ParseFunctionDeclarator(clang::Declarator&,
clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool)
/home/kcc/llvm/tools/clang/lib/Parse/ParseDecl.cpp:5080
    #3 0x44d9025 in clang::Parser::ParseDirectDeclarator(clang::Declarator&)
/home/kcc/llvm/tools/clang/lib/Parse/ParseDecl.cpp:4890
    #4 0x44d2ecd in clang::Parser::ParseDeclaratorInternal(clang::Declarator&,
void (clang::Parser::*)(clang::Declarator&))
/home/kcc/llvm/tools/clang/lib/Parse/ParseDecl.cpp:4554
    #5 0x4514fb0 in
clang::Parser::ParseCXXMemberDeclaratorBeforeInitializer(clang::Declarator&,
clang::VirtSpecifiers&, clang::ActionResult<clang::Expr*, true>&,
clang::Parser::LateParsedAttrList&)
/home/kcc/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:1922
    #6 0x4518bbc in
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
/home/kcc/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2163
    #7 0x450d6a9 in
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) /home/kcc/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2693
    #8 0x4508044 in clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
/home/kcc/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:1623
    #9 0x44a4c52 in clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
/home/kcc/llvm/tools/clang/lib/Parse/ParseDecl.cpp:3068
    #10 0x446c13f in
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/home/kcc/llvm/tools/clang/lib/Parse/Parser.cpp:829
    #11 0x446b7c5 in
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
/home/kcc/llvm/tools/clang/lib/Parse/Parser.cpp:902
    #12 0x4468009 in
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) /home/kcc/llvm/tools/clang/lib/Parse/Parser.cpp:760
    #13 0x4465a48 in
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
/home/kcc/llvm/tools/clang/lib/Parse/Parser.cpp:557
    #14 0x44586b0 in clang::ParseAST(clang::Sema&, bool, bool)
/home/kcc/llvm/tools/clang/lib/Parse/ParseAST.cpp:135
    #15 0x295d3fa in clang::FrontendAction::Execute()
/home/kcc/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:402
    #16 0x28dfea7 in
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/kcc/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:720
    #17 0x2ab531e in clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/kcc/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:239
    #18 0x7e749a in cc1_main(char const**, char const**, char const*, void*)
/home/kcc/llvm/tools/clang/tools/driver/cc1_main.cpp:112
    #19 0x7e2afd in main /home/kcc/llvm/tools/clang/tools/driver/driver.cpp:318
    #20 0x7f34c157a76c in __libc_start_main
/build/buildd/eglibc-2.15/csu/libc-start.c:226


The leak:

      if (Tok.is(tok::equal)) {
        SourceLocation EqualLoc = Tok.getLocation();

        // Parse the default argument
        if (D.getContext() == Declarator::MemberContext) {
          // If we're inside a class definition, cache the tokens
          // corresponding to the default argument. We'll actually parse
          // them when we see the end of the class definition.
          // FIXME: Can we use a smart pointer for Toks?
          DefArgToks = new CachedTokens;

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140508/1a540d82/attachment.html>


More information about the llvm-bugs mailing list