[llvm-bugs] [Bug 51613] New: Clang hangs until out of memory on undeclared identifier

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 24 22:52:17 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51613

            Bug ID: 51613
           Summary: Clang hangs until out of memory on undeclared
                    identifier
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: 0e4ef622 at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

When attempting to compile this C++ file:

    #include <cmath>
    void f(int) {}
    void g() {
        int last;
        f(dist), f(dist);
    }

clang hangs and consumes memory until killed or out of memory.

$ clang --version
clang version 12.0.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ ulimit -v 1048576; clang++ clanguok.cpp

LLVM ERROR: out of memory
Allocation failed
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/bin/clang-12 -cc1 -triple x86_64-pc-linux-gnu
-emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name clanguok.cpp -mrelocation-model pic
-pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -fno-rounding-math
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic
-fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/usr/lib/clang/12.0.1 -internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/x86_64-pc-linux-gnu
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/clang/12.0.1/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /tmp/bug -ferror-limit 19 -stack-protector 2
-fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics
-faddrsig -o /tmp/clanguok-a3e21c.o -x c++ clanguok.cpp
1.      clanguok.cpp:6:1: current parser token '}'
2.      clanguok.cpp:3:10: parsing function body 'g'
3.      clanguok.cpp:3:10: in compound statement ('{}')
 #0 0x00007fbd5750a793 (/usr/bin/../lib/libLLVM-12.so+0xb49793)
 #1 0x00007fbd57507e96 (/usr/bin/../lib/libLLVM-12.so+0xb46e96)
 #2 0x00007fbd5661bda0 __restore_rt (/usr/bin/../lib/libc.so.6+0x3cda0)
 #3 0x00007fbd5661bd22 raise (/usr/bin/../lib/libc.so.6+0x3cd22)
 #4 0x00007fbd56605862 abort (/usr/bin/../lib/libc.so.6+0x26862)
 #5 0x00007fbd5742e81a llvm::report_bad_alloc_error(char const*, bool)
(/usr/bin/../lib/libLLVM-12.so+0xa6d81a)
 #6 0x00007fbd5742e855 (/usr/bin/../lib/libLLVM-12.so+0xa6d855)
 #7 0x00007fbd56851465 operator new(unsigned long)
/build/gcc/src/gcc/libstdc++-v3/libsupc++/new_op.cc:55:15
 #8 0x00007fbd5d930701 clang::UnresolvedLookupExpr::Create(clang::ASTContext
const&, clang::CXXRecordDecl*, clang::NestedNameSpecifierLoc,
clang::DeclarationNameInfo const&, bool, bool, clang::UnresolvedSetIterator,
clang::UnresolvedSetIterator) (/usr/bin/../lib/libclang-cpp.so.12+0xcc4701)
 #9 0x00007fbd5e0173b2
clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&,
clang::LookupResult&, bool, bool)
(/usr/bin/../lib/libclang-cpp.so.12+0x13ab3b2)
#10 0x00007fbd5e119f27 (/usr/bin/../lib/libclang-cpp.so.12+0x14adf27)
#11 0x00007fbd5e11e0f7 (/usr/bin/../lib/libclang-cpp.so.12+0x14b20f7)
#12 0x00007fbd5e11bcad (/usr/bin/../lib/libclang-cpp.so.12+0x14afcad)
#13 0x00007fbd5e0e8db8 (/usr/bin/../lib/libclang-cpp.so.12+0x147cdb8)
#14 0x00007fbd5e0e9dd7 clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*,
clang::VarDecl*, bool, llvm::function_ref<clang::ActionResult<clang::Expr*,
true> (clang::Expr*)>) (/usr/bin/../lib/libclang-cpp.so.12+0x147ddd7)
#15 0x00007fbd5e0ec47b clang::Sema::ActOnFinishFullExpr(clang::Expr*,
clang::SourceLocation, bool, bool)
(/usr/bin/../lib/libclang-cpp.so.12+0x148047b)
#16 0x00007fbd5e2faf9d
clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>, bool)
(/usr/bin/../lib/libclang-cpp.so.12+0x168ef9d)
#17 0x00007fbd5d657f34
clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext)
(/usr/bin/../lib/libclang-cpp.so.12+0x9ebf34)
#18 0x00007fbd5d6586fb
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/usr/bin/../lib/libclang-cpp.so.12+0x9ec6fb)
#19 0x00007fbd5d659468
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/usr/bin/../lib/libclang-cpp.so.12+0x9ed468)
#20 0x00007fbd5d65a20a clang::Parser::ParseCompoundStatementBody(bool)
(/usr/bin/../lib/libclang-cpp.so.12+0x9ee20a)
#21 0x00007fbd5d65cdfb clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/bin/../lib/libclang-cpp.so.12+0x9f0dfb)
#22 0x00007fbd5d68f63a
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/bin/../lib/libclang-cpp.so.12+0xa2363a)
#23 0x00007fbd5d5cc2e1 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/bin/../lib/libclang-cpp.so.12+0x9602e1)
#24 0x00007fbd5d68b1e5 (/usr/bin/../lib/libclang-cpp.so.12+0xa1f1e5)
#25 0x00007fbd5d6918ae
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/bin/../lib/libclang-cpp.so.12+0xa258ae)
#26 0x00007fbd5d69292a
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/usr/bin/../lib/libclang-cpp.so.12+0xa2692a)
#27 0x00007fbd5d5a3432 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/bin/../lib/libclang-cpp.so.12+0x937432)
#28 0x00007fbd5efee2b9 clang::FrontendAction::Execute()
(/usr/bin/../lib/libclang-cpp.so.12+0x23822b9)
#29 0x00007fbd5ef855be
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/bin/../lib/libclang-cpp.so.12+0x23195be)
#30 0x00007fbd5f06e999
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/bin/../lib/libclang-cpp.so.12+0x2402999)
#31 0x000055df069048de cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/bin/clang-12+0x128de)
#32 0x000055df06901ee8 (/usr/bin/clang-12+0xfee8)
#33 0x000055df068fe505 main (/usr/bin/clang-12+0xc505)
#34 0x00007fbd56606b25 __libc_start_main (/usr/bin/../lib/libc.so.6+0x27b25)
#35 0x000055df0690186e _start (/usr/bin/clang-12+0xf86e)
clang-12: error: unable to execute command: Aborted (core dumped)
clang-12: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 12.0.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-12: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12: note: diagnostic msg: /tmp/clanguok-7576e9.cpp
clang-12: note: diagnostic msg: /tmp/clanguok-7576e9.sh
clang-12: note: diagnostic msg: 

********************

-- 
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/20210825/4af41dbc/attachment-0001.html>


More information about the llvm-bugs mailing list