[llvm-bugs] [Bug 29099] New: Clang crashes when parsing lambda with try catch and undefined identifiers

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 22 23:22:08 PDT 2016


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

            Bug ID: 29099
           Summary: Clang crashes when parsing lambda with try catch and
                    undefined identifiers
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rf at rufflewind.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Clang seems to crash when parsing this file:

int main()
{
    auto x = []() {
        try {
            return 0;
        } catch (...) {
            return z;
        }
    };
}

# Crash reproducer for clang version 3.8.1 (tags/RELEASE_381/final)
# Driver args: "--driver-mode=g++" "-std=c++14" "foo-b2aebf.cpp"
# Original command:  "/usr/bin/clang-3.8" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-main-file-name" "foo-b2aebf.cpp"
"-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim"
"-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables"
"-fuse-init-array" "-target-cpu" "x86-64" "-dwarf-column-info"
"-debugger-tuning=gdb" "-resource-dir" "/usr/bin/../lib/clang/3.8.1"
"-c-isystem" "/home/rf/.local/include" "-c-isystem" "/usr/local/include"
"-cxx-isystem" "/home/rf/.local/include" "-cxx-isystem" "/usr/local/include"
"-internal-isystem"
"/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1"
"-internal-isystem"
"/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu"
"-internal-isystem"
"/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/bin/../lib/clang/3.8.1/include" "-internal-externc-isystem" "/include"
"-internal-externc-isystem" "/usr/include" "-std=c++14" "-fdeprecated-macro"
"-fdebug-compilation-dir" "/home/rf/trash/clang-crash" "-ferror-limit" "19"
"-fmessage-length" "191" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-o"
"/tmp/foo-b2aebf-d18d19.o" "-x" "c++" "foo-b2aebf.cpp"
 "/usr/bin/clang-3.8" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj"
"-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-main-file-name"
"foo-b2aebf.cpp" "-mrelocation-model" "static" "-mthread-model" "posix"
"-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases"
"-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64"
"-dwarf-column-info" "-debugger-tuning=gdb" "-c-isystem"
"/home/rf/.local/include" "-c-isystem" "/usr/local/include" "-cxx-isystem"
"/home/rf/.local/include" "-cxx-isystem" "/usr/local/include" "-std=c++14"
"-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length" "191"
"-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-x" "c++"
"foo-b2aebf-43bb51.cpp"

0  libLLVM-3.8.so 0x00007f3c87a087d8
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 56
1  libLLVM-3.8.so 0x00007f3c87a063c6 llvm::sys::RunSignalHandlers() + 54
2  libLLVM-3.8.so 0x00007f3c87a065aa
3  libc.so.6      0x00007f3c86b0f0b0
4  clang-3.8      0x0000000001450e87
clang::ASTContext::getCanonicalFunctionResultType(clang::QualType) const + 7
5  clang-3.8      0x000000000103dfc4
clang::Sema::DeduceFunctionTypeFromReturnExpr(clang::FunctionDecl*,
clang::SourceLocation, clang::Expr*&, clang::AutoType*) + 324
6  clang-3.8      0x000000000103e4a6
clang::Sema::ActOnCapScopeReturnStmt(clang::SourceLocation, clang::Expr*) + 246
7  clang-3.8      0x000000000103ed7f
clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*) + 591
8  clang-3.8      0x000000000103f63a
clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*,
clang::Scope*) + 42
9  clang-3.8      0x0000000000c0c7ff clang::Parser::ParseReturnStatement() +
223
10 clang-3.8      0x0000000000c0e58f
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) + 2255
11 clang-3.8      0x0000000000c0eb87
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*) + 135
12 clang-3.8      0x0000000000c13949
clang::Parser::ParseCompoundStatementBody(bool) + 1769
13 clang-3.8      0x0000000000c140be
clang::Parser::ParseCompoundStatement(bool, unsigned int) + 30
14 clang-3.8      0x0000000000c140f2
clang::Parser::ParseCompoundStatement(bool) + 18
15 clang-3.8      0x0000000000c15652 clang::Parser::ParseCXXCatchBlock(bool) +
2626
16 clang-3.8      0x0000000000c15cf2
clang::Parser::ParseCXXTryBlockCommon(clang::SourceLocation, bool) + 370
17 clang-3.8      0x0000000000c15ed4 clang::Parser::ParseCXXTryBlock() + 36
18 clang-3.8      0x0000000000c0e4c8
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) + 2056
19 clang-3.8      0x0000000000c0eb87
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*) + 135
20 clang-3.8      0x0000000000c13949
clang::Parser::ParseCompoundStatementBody(bool) + 1769
21 clang-3.8      0x0000000000be6902
clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) +
2114
22 clang-3.8      0x0000000000be78eb clang::Parser::ParseLambdaExpression() +
331
23 clang-3.8      0x0000000000bcf8ca clang::Parser::ParseCastExpression(bool,
bool, bool&, clang::Parser::TypeCastState) + 5162
24 clang-3.8      0x0000000000bd0b0d clang::Parser::ParseCastExpression(bool,
bool, clang::Parser::TypeCastState) + 45
25 clang-3.8      0x0000000000bd0ba9
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 41
26 clang-3.8      0x0000000000ba4443
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) + 835
27 clang-3.8      0x0000000000bb2298
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1544
28 clang-3.8      0x0000000000bb53c1
clang::Parser::ParseSimpleDeclaration(unsigned int, clang::SourceLocation&,
clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit*)
+ 833
29 clang-3.8      0x0000000000bb5686 clang::Parser::ParseDeclaration(unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 214
30 clang-3.8      0x0000000000c0e95f
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) + 3231
31 clang-3.8      0x0000000000c0eb87
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*) + 135
32 clang-3.8      0x0000000000c13949
clang::Parser::ParseCompoundStatementBody(bool) + 1769
33 clang-3.8      0x0000000000c1673a
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 314
34 clang-3.8      0x0000000000b93b28
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) +
1240
35 clang-3.8      0x0000000000bb2832
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 2978
36 clang-3.8      0x0000000000b8f062
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 290
37 clang-3.8      0x0000000000b8f6d1
38 clang-3.8      0x0000000000b8f70f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 31
39 clang-3.8      0x0000000000b969af
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 287
40 clang-3.8      0x0000000000b973ac
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 460
41 clang-3.8      0x0000000000b8a9d0 clang::ParseAST(clang::Sema&, bool, bool)
+ 672
42 clang-3.8      0x00000000009c2a2e clang::FrontendAction::Execute() + 302
43 clang-3.8      0x00000000009968a6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 278
44 clang-3.8      0x0000000000a41c33
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2339
45 clang-3.8      0x00000000006a7918 cc1_main(llvm::ArrayRef<char const*>, char
const*, void*) + 2456
46 clang-3.8      0x00000000006a3b38 main + 5832
47 libc.so.6      0x00007f3c86afc291 __libc_start_main + 241
48 clang-3.8      0x00000000006a5889 _start + 41
Stack dump:
0.    Program arguments: /usr/bin/clang-3.8 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name foo-b2aebf.cpp -mrelocation-model static
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/bin/../lib/clang/3.8.1 -c-isystem /home/rf/.local/include -c-isystem
/usr/local/include -cxx-isystem /home/rf/.local/include -cxx-isystem
/usr/local/include -internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib/clang/3.8.1/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++14 -fdeprecated-macro
-fdebug-compilation-dir /home/rf/trash/clang-crash -ferror-limit 19
-fmessage-length 191 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/foo-b2aebf-d18d19.o -x
c++ foo-b2aebf.cpp 
1.    foo-b2aebf.cpp:7:21: current parser token ';'
2.    foo-b2aebf.cpp:2:1: parsing function body 'main'
3.    foo-b2aebf.cpp:2:1: in compound statement ('{}')
4.    foo-b2aebf.cpp:3:14: lambda expression parsing
5.    foo-b2aebf.cpp:3:19: in compound statement ('{}')
6.    foo-b2aebf.cpp:6:23: in compound statement ('{}')
clang-3.8: error: unable to execute command: Segmentation fault (core dumped)
clang-3.8: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.1 (tags/RELEASE_381/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

-- 
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/20160823/3fd5d001/attachment-0001.html>


More information about the llvm-bugs mailing list