llvm / llvm-project

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

Clang-19 crashed: Assertion `isa<X>(Val) && "cast_if_present<Ty>() argument of incompatible type!"' failed. with #pragma omp #96383

Open iamanonymouscs opened 2 months ago

iamanonymouscs commented 2 months ago

Clang-19 crashed with the #pragma omp enabled.

Compiler explorer(assertion trunck): https://godbolt.org/z/nMEbj11jr

$cat mutant.c
a;
b() {
#pragma omp tile sizes(8)
  for (a = 0; a < 2; a = a + 3)
    ;
}

$clang-19 -fsanitize=undefined -fopenmp-simd mutant.c
mutant.c:1:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
    1 | a;
      | ^
      | int
mutant.c:2:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
    2 | b() {
      | ^
      | int
clang-19: /root/new_git/llvm-project/llvm/include/llvm/Support/Casting.h:706: auto llvm::cast_if_present(Y *) [X = clang::CapturedStmt, Y = const clang::Stmt]: Assertion `isa<X>(Val) && "cast_if_present<Ty>() argument of incompatible type!"' 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: /root/llvm_set/7500646/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name mutant.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/code/my_code/diff_coverage/combine_test/case_reduce -fcoverage-compilation-dir=/root/code/my_code/diff_coverage/combine_test/case_reduce -resource-dir /root/llvm_set/7500646/lib/clang/19 -internal-isystem /root/llvm_set/7500646/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fopenmp-simd -fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr -fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr -fno-sanitize-memory-param-retval -fno-sanitize-address-use-odr-indicator -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-f05ab7.o -x c mutant.c
1.      <eof> parser at end of file
2.      mutant.c:2:1: LLVM IR generation of declaration 'b'
3.      mutant.c:2:1: Generating code for declaration 'b'
 #0 0x00007f15e9d25e37 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/root/llvm_set/7500646/bin/../lib/libLLVM.so.19.0git+0xfade37)
 #1 0x00007f15e9d221a2 llvm::sys::RunSignalHandlers() (/root/llvm_set/7500646/bin/../lib/libLLVM.so.19.0git+0xfaa1a2)
 #2 0x00007f15e9d265e9 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f1616db0980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00007f15e7f8fe87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f15e7f917f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f15e7f813fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f15e7f81472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
 #8 0x00007f16072e13bb (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3dc73bb)
 #9 0x00007f16072d8b54 (anonymous namespace)::OMPSimdLexicalScope::OMPSimdLexicalScope(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&) CGStmtOpenMP.cpp:0:0
#10 0x00007f16072d7659 clang::CodeGen::CodeGenFunction::EmitSimpleOMPExecutableDirective(clang::OMPExecutableDirective const&) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3dbd659)
#11 0x00007f16072623ae clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3d483ae)
#12 0x00007f1607279653 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3d5f653)
#13 0x00007f160734dda8 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e33da8)
#14 0x00007f160734f768 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e35768)
#15 0x00007f1607396884 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e7c884)
#16 0x00007f1607389127 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e6f127)
#17 0x00007f1607390205 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e76205)
#18 0x00007f160738771f clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e6d71f)
#19 0x00007f1607500ac4 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#20 0x00007f160732715c clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e0d15c)
#21 0x00007f160439812b clang::ParseAST(clang::Sema&, bool, bool) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0xe7e12b)
#22 0x00007f1608c13495 clang::FrontendAction::Execute() (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x56f9495)
#23 0x00007f1608ac83cb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x55ae3cb)
#24 0x00007f1608d14116 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x57fa116)
#25 0x000055c9c9aadc19 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/root/llvm_set/7500646/bin/clang-19+0x1bc19)
#26 0x000055c9c9aa3a65 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x000055c9c9aa2409 clang_main(int, char**, llvm::ToolContext const&) (/root/llvm_set/7500646/bin/clang-19+0x10409)
#28 0x000055c9c9ac8785 main (/root/llvm_set/7500646/bin/clang-19+0x36785)
#29 0x00007f15e7f72c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#30 0x000055c9c9a9f6fa _start (/root/llvm_set/7500646/bin/clang-19+0xd6fa)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 75006466296ed4b0f845cbbec4bf77c21de43b40)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /root/llvm_set/7500646/bin
Build config: +assertions
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/mutant-63a760.c
clang: note: diagnostic msg: /tmp/mutant-63a760.sh
clang: note: diagnostic msg: 

********************
llvmbot commented 2 months ago

@llvm/issue-subscribers-clang-codegen

Author: Anonymous (iamanonymouscs)

Clang-19 crashed with the `#pragma omp` enabled. Compiler explorer(assertion trunck): https://godbolt.org/z/nMEbj11jr ``` $cat mutant.c a; b() { #pragma omp tile sizes(8) for (a = 0; a < 2; a = a + 3) ; } $clang-19 -fsanitize=undefined -fopenmp-simd mutant.c mutant.c:1:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int] 1 | a; | ^ | int mutant.c:2:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int] 2 | b() { | ^ | int clang-19: /root/new_git/llvm-project/llvm/include/llvm/Support/Casting.h:706: auto llvm::cast_if_present(Y *) [X = clang::CapturedStmt, Y = const clang::Stmt]: Assertion `isa<X>(Val) && "cast_if_present<Ty>() argument of incompatible type!"' 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: /root/llvm_set/7500646/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name mutant.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/code/my_code/diff_coverage/combine_test/case_reduce -fcoverage-compilation-dir=/root/code/my_code/diff_coverage/combine_test/case_reduce -resource-dir /root/llvm_set/7500646/lib/clang/19 -internal-isystem /root/llvm_set/7500646/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fopenmp-simd -fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr -fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr -fno-sanitize-memory-param-retval -fno-sanitize-address-use-odr-indicator -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-f05ab7.o -x c mutant.c 1. <eof> parser at end of file 2. mutant.c:2:1: LLVM IR generation of declaration 'b' 3. mutant.c:2:1: Generating code for declaration 'b' #0 0x00007f15e9d25e37 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/root/llvm_set/7500646/bin/../lib/libLLVM.so.19.0git+0xfade37) #1 0x00007f15e9d221a2 llvm::sys::RunSignalHandlers() (/root/llvm_set/7500646/bin/../lib/libLLVM.so.19.0git+0xfaa1a2) #2 0x00007f15e9d265e9 SignalHandler(int) Signals.cpp:0:0 #3 0x00007f1616db0980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980) #4 0x00007f15e7f8fe87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0 #5 0x00007f15e7f917f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0 #6 0x00007f15e7f813fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0 #7 0x00007f15e7f81472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472) #8 0x00007f16072e13bb (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3dc73bb) #9 0x00007f16072d8b54 (anonymous namespace)::OMPSimdLexicalScope::OMPSimdLexicalScope(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&) CGStmtOpenMP.cpp:0:0 #10 0x00007f16072d7659 clang::CodeGen::CodeGenFunction::EmitSimpleOMPExecutableDirective(clang::OMPExecutableDirective const&) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3dbd659) #11 0x00007f16072623ae clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3d483ae) #12 0x00007f1607279653 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3d5f653) #13 0x00007f160734dda8 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e33da8) #14 0x00007f160734f768 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e35768) #15 0x00007f1607396884 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e7c884) #16 0x00007f1607389127 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e6f127) #17 0x00007f1607390205 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e76205) #18 0x00007f160738771f clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e6d71f) #19 0x00007f1607500ac4 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0 #20 0x00007f160732715c clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x3e0d15c) #21 0x00007f160439812b clang::ParseAST(clang::Sema&, bool, bool) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0xe7e12b) #22 0x00007f1608c13495 clang::FrontendAction::Execute() (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x56f9495) #23 0x00007f1608ac83cb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x55ae3cb) #24 0x00007f1608d14116 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/root/llvm_set/7500646/bin/../lib/libclang-cpp.so.19.0git+0x57fa116) #25 0x000055c9c9aadc19 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/root/llvm_set/7500646/bin/clang-19+0x1bc19) #26 0x000055c9c9aa3a65 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0 #27 0x000055c9c9aa2409 clang_main(int, char**, llvm::ToolContext const&) (/root/llvm_set/7500646/bin/clang-19+0x10409) #28 0x000055c9c9ac8785 main (/root/llvm_set/7500646/bin/clang-19+0x36785) #29 0x00007f15e7f72c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0 #30 0x000055c9c9a9f6fa _start (/root/llvm_set/7500646/bin/clang-19+0xd6fa) clang: error: unable to execute command: Aborted (core dumped) clang: error: clang frontend command failed due to signal (use -v to see invocation) clang version 19.0.0git (https://github.com/llvm/llvm-project.git 75006466296ed4b0f845cbbec4bf77c21de43b40) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /root/llvm_set/7500646/bin Build config: +assertions clang: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang: note: diagnostic msg: /tmp/mutant-63a760.c clang: note: diagnostic msg: /tmp/mutant-63a760.sh clang: note: diagnostic msg: ******************** ```