llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

`clangtk` crashes at clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::StmtProfiler, void>::Visit(clang::Stmt const*)

Open wierton opened this issue 2 years ago • 1 comments

The bug triggering program:

void a(void) {}
void b(void) {
  int c = 0, d = 0;
#pragma omp atomic capture
  {
    d = c;
    c = a();
  }
}

When attempting to compile it using clangtk with option -O0 -fopenmp-simd, clangtk crashes with below output log (verification link: https://gcc.godbolt.org/z/9TohYb7T6):

<source>:7:7: error: assigning to 'int' from incompatible type 'void'
    7 |     c = a();
      |       ^ ~~~
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-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 -fopenmp-simd <source>
1.	<source>:9:1: current parser token '}'
2.	<source>:2:14: parsing function body 'b'
3.	<source>:2:14: in compound statement ('{}')
 #0 0x000055afe082616f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x362e16f)
 #1 0x000055afe082419c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x362c19c)
 #2 0x000055afe0773e58 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f97553a7420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x000055afe403d35b clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::StmtProfiler, void>::Visit(clang::Stmt const*) StmtProfile.cpp:0:0
 #5 0x000055afe40434ef clang::Stmt::Profile(llvm::FoldingSetNodeID&, clang::ASTContext const&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x6e4b4ef)
 #6 0x000055afe357976c clang::Sema::ActOnOpenMPAtomicDirective(llvm::ArrayRef<clang::OMPClause*>, clang::Stmt*, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+0x638176c)
 #7 0x000055afe35fe1bc clang::Sema::ActOnOpenMPExecutableDirective(llvm::omp::Directive, clang::DeclarationNameInfo const&, llvm::omp::Directive, llvm::ArrayRef<clang::OMPClause*>, clang::Stmt*, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+0x64061bc)
 #8 0x000055afe2e45612 clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c4d612)
 #9 0x000055afe2e6750c clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c6f50c)
#10 0x000055afe2e69181 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c71181)
#11 0x000055afe2e69ff9 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c71ff9)
#12 0x000055afe2e6c2e2 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c742e2)
#13 0x000055afe2d878d0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b8f8d0)
#14 0x000055afe2db9fdf clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5bc1fdf)
#15 0x000055afe2d81d26 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b89d26)
#16 0x000055afe2d82e8f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#17 0x000055afe2d8a90f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b9290f)
#18 0x000055afe2d8be56 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b93e56)
#19 0x000055afe2d7b39a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b8339a)
#20 0x000055afe19bf20d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x47c720d)
#21 0x000055afe129ad61 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x40a2d61)
#22 0x000055afe1220193 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4028193)
#23 0x000055afe137bd03 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4183d03)
#24 0x000055afde09b72c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xea372c)
#25 0x000055afde096def ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x000055afe107390d 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
#27 0x000055afe07742d7 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x357c2d7)
#28 0x000055afe1073dac 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
#29 0x000055afe103ac9e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e42c9e)
#30 0x000055afe103b66d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e4366d)
#31 0x000055afe1045d3c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e4dd3c)
#32 0x000055afde0992ef clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xea12ef)
#33 0x000055afddf957b5 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xd9d7b5)
#34 0x00007f9754e55083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#35 0x000055afde0930ce _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xe9b0ce)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139

wierton avatar Jun 26 '23 14:06 wierton

@llvm/issue-subscribers-clang-frontend

llvmbot avatar Jun 26 '23 14:06 llvmbot