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

`clangtk` crashes at clang::Expr::IgnoreImpCasts

Open wierton opened this issue 2 years ago • 1 comments

The bug triggering testcase:

#include <limits.h>
#include <stdint.h>
typedef enum omp_allocator_handle_t : uintptr_t {
  omp_default_mem_alloc = 1,
} omp_allocator_handle_t;
int r, bar(int, int *, int);
void foo(void) {
#pragma omp taskgroup task_reduction(+ : r) allocate(omp_default_mem_alloc : r)
#pragma omp task in_reduction(+ : r) allocate(omp_default_mem_alloc : r)
  bar(r, &r, 0);
}

When attempting to compile this program using clangtk with option -O0 -fopenmp-simd, clangtk crashes with the following output (can be verified at https://gcc.godbolt.org/z/9K88sazY7):

<source>:8:54: error: 'omp_allocator_handle_t' type not found; include <omp.h>
    8 | #pragma omp taskgroup task_reduction(+ : r) allocate(omp_default_mem_alloc : r)
      |                                                      ^
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>:11:1: current parser token '}'
2.	<source>:7:16: parsing function body 'foo'
3.	<source>:7:16: in compound statement ('{}')
 #0 0x0000561eb88c716f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x362e16f)
 #1 0x0000561eb88c519c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x362c19c)
 #2 0x0000561eb8814e58 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f3508428420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x0000561ebbe94d2c clang::Expr::IgnoreImpCasts() (/opt/compiler-explorer/clang-trunk/bin/clang+0x6bfbd2c)
 #5 0x0000561ebb5dc9f9 getAllocatorKind(clang::Sema&, (anonymous namespace)::DSAStackTy*, clang::Expr*) (.part.0) SemaOpenMP.cpp:0:0
 #6 0x0000561ebb63044f clang::Sema::EndOpenMPDSABlock(clang::Stmt*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x639744f)
 #7 0x0000561ebaee662a clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c4d62a)
 #8 0x0000561ebaf0850c 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)
 #9 0x0000561ebaf0a181 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c71181)
#10 0x0000561ebaf0f348 clang::Parser::ParseStatement(clang::SourceLocation*, clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c76348)
#11 0x0000561ebaee65a5 clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c4d5a5)
#12 0x0000561ebaf0850c 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)
#13 0x0000561ebaf0a181 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c71181)
#14 0x0000561ebaf0aff9 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c71ff9)
#15 0x0000561ebaf0d2e2 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c742e2)
#16 0x0000561ebae288d0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b8f8d0)
#17 0x0000561ebae5afdf clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5bc1fdf)
#18 0x0000561ebae22d26 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b89d26)
#19 0x0000561ebae23e8f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#20 0x0000561ebae2b90f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b9290f)
#21 0x0000561ebae2ce56 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b93e56)
#22 0x0000561ebae1c39a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b8339a)
#23 0x0000561eb9a6020d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x47c720d)
#24 0x0000561eb933bd61 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x40a2d61)
#25 0x0000561eb92c1193 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4028193)
#26 0x0000561eb941cd03 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4183d03)
#27 0x0000561eb613c72c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xea372c)
#28 0x0000561eb6137def ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x0000561eb911490d 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
#30 0x0000561eb88152d7 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x357c2d7)
#31 0x0000561eb9114dac 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
#32 0x0000561eb90dbc9e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e42c9e)
#33 0x0000561eb90dc66d 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)
#34 0x0000561eb90e6d3c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e4dd3c)
#35 0x0000561eb613a2ef clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xea12ef)
#36 0x0000561eb60367b5 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xd9d7b5)
#37 0x00007f3507ed6083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#38 0x0000561eb61340ce _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 09:06 wierton

@llvm/issue-subscribers-clang-frontend

llvmbot avatar Jun 26 '23 10:06 llvmbot