llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.34k stars 11.7k forks source link

Assertion `Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData()' failed. #44269

Open llvmbot opened 4 years ago

llvmbot commented 4 years ago
Bugzilla Link 44924
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @zygoloid

Extended Description

POC:

a ( ( void ( struct { ; ) ) 0

Run script:

clang++ -o tmp ./poc.cpp

Stack dump:

clang++: /home/rxz226/llvm-project/clang/lib/Parse/ParseExprCXX.cpp:3843: clang::ExprResult clang::Parser::ParseCXXAmbiguousParenExpression(clang::Parser::ParenParseOption&, clang::ParsedType&, clang::BalancedDelimiterTracker&, clang::ColonProtectionRAIIObject&): Assertion `Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData()' failed. Stack dump:

  1. Program arguments: /home/rxz226/llvm-project/bld/bin/clang++ -x c++ -o tm ./test1.c
  2. ./test1.c:2:24: current parser token ''

    ​0 0x000000000511679b llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/rxz226/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:0

    ​1 0x000000000511682e PrintStackTraceSignalHandler(void*) /home/rxz226/llvm-project/llvm/lib/Support/Unix/Signals.inc:625:0

    ​2 0x00000000051145b6 llvm::sys::RunSignalHandlers() /home/rxz226/llvm-project/llvm/lib/Support/Signals.cpp:68:0

    ​3 0x0000000005115fd7 llvm::sys::CleanupOnSignal(unsigned long) /home/rxz226/llvm-project/llvm/lib/Support/Unix/Signals.inc:361:0

    ​4 0x000000000501be1f (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /home/rxz226/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:80:0

    ​5 0x000000000501c2fe CrashRecoverySignalHandler(int) /home/rxz226/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:362:0

    ​6 0x00007f6f2e26f390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)

    ​7 0x00007f6f2cf7e428 raise /build/glibc-LK5gWL/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0

    ​8 0x00007f6f2cf8002a abort /build/glibc-LK5gWL/glibc-2.23/stdlib/abort.c:91:0

    ​9 0x00007f6f2cf76bd7 __assert_fail_base /build/glibc-LK5gWL/glibc-2.23/assert/assert.c:92:0

    ​10 0x00007f6f2cf76c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)

    ​11 0x0000000007a7fd0f clang::Parser::ParseCXXAmbiguousParenExpression(clang::Parser::ParenParseOption&, clang::OpaquePtr&, clang::BalancedDelimiterTracker&, clang::ColonProtectionRAIIObject&) /home/rxz226/llvm-

    project/clang/lib/Parse/ParseExprCXX.cpp:3844:0

    ​12 0x0000000007a69a48 clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr&, clang::SourceLocation&) /home/rxz226/llvm-project/clang/lib/Parse/ParseExpr.cpp:2712:0

    ​13 0x0000000007a6116d clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) /home/rxz226/llvm-project/clang/lib/Parse/ParseExpr.cpp:936:0

    ​14 0x0000000007a60d00 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) /home/rxz226/llvm-project/clang/lib/Parse/ParseExpr.cpp:668:0

    ​15 0x0000000007a5e893 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) /home/rxz226/llvm-project/clang/lib/Parse/ParseExpr.cpp:175:0

    ​16 0x0000000007a6b8d0 clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&, llvm::SmallVectorImpl&, llvm::function_ref<void ()>) /home/rxz226/llvm-project/clang/lib/Parse/ParseExpr.cpp:

    3127:0

    ​17 0x0000000007a1fdbc clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /home/rxz226/llvm-project/clang/lib/Parse/ParseDecl.c

    pp:2432:0

    ​18 0x0000000007a1e882 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation, clang::Parser::ForRangeInit) /home/rxz226/llvm-project/clang/lib/Parse/ParseDecl.cpp:2129:0

    ​19 0x00000000079ff6cd clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/rxz226/llvm-project/clang/lib/Parse/Parser.cpp:1110:0

    ​20 0x00000000079ff7ab clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/rxz226/llvm-project/clang/lib/Parse/Parser.cpp:1125:0

    ​21 0x00000000079fec86 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /home/rxz226/llvm-project/clang/lib/Parse/Parser.cpp:945:0

    ​22 0x00000000079fdf00 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, bool) /home/rxz226/llvm-project/clang/lib/Parse/Parser.cpp:696:0

    ​23 0x00000000079fd881 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&) /home/rxz226/llvm-project/clang/lib/Parse/Parser.cpp:564:0

    ​24 0x00000000079f97d7 clang::ParseAST(clang::Sema&, bool, bool) /home/rxz226/llvm-project/clang/lib/Parse/ParseAST.cpp:157:0

    ... clang-11: error: clang frontend command failed due to signal (use -v to see invocation) clang version 11.0.0 (https://github.com/llvm/llvm-project.git 56b7f595d2b402ff177ca42214325c8fdea10fb0) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/rxz226/llvm-project/bld/bin

Endilll commented 1 year ago

Still crashing as of post-17 trunk: https://godbolt.org/z/3jThvhd54

<source>:1:1: error: a type specifier is required for all declarations
    1 | a  ( ( void  ( struct {
      | ^
<source>:2:19: error: expected member name or ';' after declaration specifiers
    2 |   ;               ) ) 0
      |                   ^
<source>:2:21: error: expected member name or ';' after declaration specifiers
    2 |   ;               ) ) 0
      |                     ^
<source>:2:24: error: expected '}'
    2 |   ;               ) ) 0
      |                        ^
<source>:1:23: note: to match this '{'
    1 | a  ( ( void  ( struct {
      |                       ^
<source>:2:22: error: expected ';' after struct
    2 |   ;               ) ) 0
      |                      ^
      |                      ;
<source>:1:16: error: '(unnamed struct at <source>:1:16)' cannot be defined in a parameter type
    1 | a  ( ( void  ( struct {
      |                ^
<source>:2:24: error: expected ')'
    2 |   ;               ) ) 0
      |                        ^
<source>:1:14: note: to match this '('
    1 | a  ( ( void  ( struct {
      |              ^
<source>:2:24: error: expected ')'
    2 |   ;               ) ) 0
      |                        ^
<source>:1:6: note: to match this '('
    1 | a  ( ( void  ( struct {
      |      ^

clang++: /root/llvm-project/clang/lib/Parse/ParseExprCXX.cpp:4031:
clang::ExprResult clang::Parser::ParseCXXAmbiguousParenExpression(clang::Parser::ParenParseOption&, clang::ParsedType&, clang::BalancedDelimiterTracker&, clang::ColonProtectionRAIIObject&):
Assertion `Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData()' failed.

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.  <source>:2:24: current parser token ''
 #0 0x0000000003673848 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3673848)
 #1 0x00000000036716cc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36716cc)
 #2 0x00000000035bef28 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fc66d380420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fc66ce4300b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007fc66ce22859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007fc66ce22729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007fc66ce33fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x0000000005dfe2b4 clang::Parser::ParseCXXAmbiguousParenExpression(clang::Parser::ParenParseOption&, clang::OpaquePtr<clang::QualType>&, clang::BalancedDelimiterTracker&, clang::ColonProtectionRAIIObject&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5dfe2b4)
 #9 0x0000000005df156a clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5df156a)
#10 0x0000000005de685b clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5de685b)
#11 0x0000000005de864a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5de864a)
#12 0x0000000005de87e9 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5de87e9)
#13 0x0000000005de8b0e clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&, llvm::function_ref<void ()>, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5de8b0e)
#14 0x0000000005daa144 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5daa144)
#15 0x0000000005db6c30 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5db6c30)
#16 0x0000000005d84acb clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d84acb)
#17 0x0000000005d851ff clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#18 0x0000000005d8b7e1 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d8b7e1)
#19 0x0000000005d8c0e2 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d8c0e2)
#20 0x0000000005d8c530 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d8c530)
#21 0x0000000005d80442 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d80442)
#22 0x00000000048c5798 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48c5798)
#23 0x000000000412d9d9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x412d9d9)
#24 0x00000000040b1d6e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40b1d6e)
#25 0x000000000420dc46 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x420dc46)
#26 0x0000000000bcb672 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbcb672)
#27 0x0000000000bc3e5a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x0000000003f11c19 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#29 0x00000000035bf3d4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35bf3d4)
#30 0x0000000003f1220f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#31 0x0000000003eda175 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eda175)
#32 0x0000000003edabdd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3edabdd)
#33 0x0000000003ee2705 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ee2705)
#34 0x0000000000bc9927 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbc9927)
#35 0x0000000000ac39f1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xac39f1)
#36 0x00007fc66ce24083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#37 0x0000000000bc393e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbc393e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)