llvm / llvm-project

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

crash on x86_64-linux-gnu (Assertion `isa<T>(CanonicalType)' failed.) #29804

Open chengniansun opened 8 years ago

chengniansun commented 8 years ago
Bugzilla Link 30456
Version trunk
OS Windows NT
CC @zmodem

Extended Description

$ clang-trunk -v
clang version 4.0.0 (trunk 281908) (llvm/trunk 281907)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ 
$ clang-trunk small.c
clang-4.0: /tmp/llvm-builder/llvm-source-trunk/tools/clang/include/clang/AST/Type.h:5941: const T* clang::Type::castAs() const [with T = clang::PointerType]: Assertion `isa<T>(CanonicalType)' failed.
#0 0x0000000001c9e155 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/clang-trunk/bin/clang-4.0+0x1c9e155)
#1 0x0000000001c9c0fe llvm::sys::RunSignalHandlers() (/usr/local/clang-trunk/bin/clang-4.0+0x1c9c0fe)
#2 0x0000000001c9c262 SignalHandler(int) (/usr/local/clang-trunk/bin/clang-4.0+0x1c9c262)
#3 0x00007fb1437fa340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007fb1425ebcc9 gsignal /build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fb1425ef0d8 abort /build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fb1425e4b86 __assert_fail_base /build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fb1425e4c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000001f2c13b clang::PointerType const* clang::Type::castAs<clang::PointerType>() const (/usr/local/clang-trunk/bin/clang-4.0+0x1f2c13b)
#9 0x000000000322b8c9 (anonymous namespace)::IntExprEvaluator::VisitCallExpr(clang::CallExpr const*) (/usr/local/clang-trunk/bin/clang-4.0+0x322b8c9)
#10 0x000000000322cd91 clang::StmtVisitorBase<clang::make_const_ptr, (anonymous namespace)::IntExprEvaluator, bool>::Visit(clang::Stmt const*) (/usr/local/clang-trunk/bin/clang-4.0+0x322cd91)
#11 0x0000000003221150 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) (/usr/local/clang-trunk/bin/clang-4.0+0x3221150)
#12 0x00000000032228d1 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) (/usr/local/clang-trunk/bin/clang-4.0+0x32228d1)
#13 0x0000000003222bac clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&) const [clone .part.1962] (/usr/local/clang-trunk/bin/clang-4.0+0x3222bac)
#14 0x0000000003222c3e clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&) const (/usr/local/clang-trunk/bin/clang-4.0+0x3222c3e)
#15 0x000000000204c40c clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::FunctionDecl const*, unsigned int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/usr/local/clang-trunk/bin/clang-4.0+0x204c40c)
#16 0x0000000001f85c47 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/usr/local/clang-trunk/bin/clang-4.0+0x1f85c47)
#17 0x000000000086b676 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) (/usr/local/clang-trunk/bin/clang-4.0+0x86b676)
#18 0x0000000001faa2b9 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) (/usr/local/clang-trunk/bin/clang-4.0+0x1faa2b9)
#19 0x0000000001fab063 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/usr/local/clang-trunk/bin/clang-4.0+0x1fab063)
#20 0x0000000001f732c7 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/usr/local/clang-trunk/bin/clang-4.0+0x1f732c7)
#21 0x0000000001f83fdb clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/usr/local/clang-trunk/bin/clang-4.0+0x1f83fdb)
#22 0x0000000001e34d89 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) (/usr/local/clang-trunk/bin/clang-4.0+0x1e34d89)
#23 0x0000000001e35bd7 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/local/clang-trunk/bin/clang-4.0+0x1e35bd7)
#24 0x0000000001e5c7f4 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&, clang::Stmt const*) (/usr/local/clang-trunk/bin/clang-4.0+0x1e5c7f4)
#25 0x0000000001e66bae clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/local/clang-trunk/bin/clang-4.0+0x1e66bae)
#26 0x0000000001e874fb clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-4.0+0x1e874fb)
#27 0x0000000001e9a5f1 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-4.0+0x1e9a5f1)
#28 0x0000000001e9b9d0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/local/clang-trunk/bin/clang-4.0+0x1e9b9d0)
#29 0x0000000001e9c111 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) [clone .part.5735] (/usr/local/clang-trunk/bin/clang-4.0+0x1e9c111)
#30 0x00000000024026b3 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/local/clang-trunk/bin/clang-4.0+0x24026b3)
#31 0x00000000023fc74d clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/local/clang-trunk/bin/clang-4.0+0x23fc74d)
#32 0x00000000027d4026 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/clang-trunk/bin/clang-4.0+0x27d4026)
#33 0x00000000023fd3fe clang::CodeGenAction::ExecuteAction() (/usr/local/clang-trunk/bin/clang-4.0+0x23fd3fe)
#34 0x0000000002110bd6 clang::FrontendAction::Execute() (/usr/local/clang-trunk/bin/clang-4.0+0x2110bd6)
#35 0x00000000020eb2de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/clang-trunk/bin/clang-4.0+0x20eb2de)
#36 0x00000000021987c6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/clang-trunk/bin/clang-4.0+0x21987c6)
#37 0x0000000000a8c9f8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/clang-trunk/bin/clang-4.0+0xa8c9f8)
#38 0x0000000000a35401 main (/usr/local/clang-trunk/bin/clang-4.0+0xa35401)
#39 0x00007fb1425d6ec5 __libc_start_main /build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#40 0x0000000000a88a1e _start (/usr/local/clang-trunk/bin/clang-4.0+0xa88a1e)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-4.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name small.c -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/local/clang-trunk/bin/../lib/clang/4.0.0 -c-isystem . -c-isystem /usr/local/include/csmith -c-isystem /usr/local/include/csmith -internal-isystem /usr/local/include -internal-isystem /usr/local/clang-trunk/bin/../lib/clang/4.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/cnsun/workspace/meta-compiler/error-fuzzer/exp-runs/crash/RandomTokenManipulationFuzzingEngine/20160915-clang-trunk--Weverything-O3-c-std=c11-build-155612 -ferror-limit 19 -fmessage-length 127 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/small-c1a718.o -x c small.c 
1.      <eof> parser at end of file
2.      small.c:1:6: LLVM IR generation of declaration 'ds'
3.      small.c:1:6: Generating code for declaration 'ds'
clang-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 4.0.0 (trunk 281908) (llvm/trunk 281907)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-4.0: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-4.0: note: diagnostic msg: 
********************

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

********************
$ 
$ cat small.c 
void ds() { __atomic_is_lock_free(2, ds); }
$
zmodem commented 7 years ago

Reproduces at least back to 3.5, so not a recent regression

k-mana commented 1 year ago

Still crashes on current trunk: https://godbolt.org/z/zK1xf3EKW

code

// clang -x c
void ds() { __atomic_is_lock_free(2, ds); }

backtrace

clang++: /root/llvm-project/clang/include/clang/AST/Type.h:7502: const T* clang::Type::castAs() const [with T = clang::PointerType]: Assertion `isa<T>(CanonicalType)' 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 -x c <source>
1.  <eof> parser at end of file
2.  <source>:2:6: LLVM IR generation of declaration 'ds'
3.  <source>:2:6: Generating code for declaration 'ds'
 #0 0x000055777a0a673f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c1873f)
 #1 0x000055777a0a44ac llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c164ac)
 #2 0x0000557779fedb28 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f5b3270c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f5b321d900b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007f5b321b8859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f5b321b8729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007f5b321c9fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x000055777d9235a3 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74955a3)
 #9 0x000055777d9ade77 (anonymous namespace)::IntExprEvaluator::VisitBuiltinCallExpr(clang::CallExpr const*, unsigned int) ExprConstant.cpp:0:0
#10 0x000055777d9ae542 (anonymous namespace)::IntExprEvaluator::VisitCallExpr(clang::CallExpr const*) ExprConstant.cpp:0:0
#11 0x000055777d95b49e clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::IntExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#12 0x000055777d949fb6 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:0:0
#13 0x000055777d953cd9 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#14 0x000055777d95541f clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74c741f)
#15 0x000055777a6c2b08 clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::GlobalDecl, unsigned int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4234b08)
#16 0x000055777a795e33 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4307e33)
#17 0x000055777a7ded6d (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#18 0x000055777a7d598c clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#19 0x000055777a7ddd54 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x434fd54)
#20 0x000055777a77139e clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42e339e)
#21 0x000055777a7936cb clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43056cb)
#22 0x000055777a3d5dd7 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f47dd7)
#23 0x000055777a3dca14 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f4ea14)
#24 0x000055777a43ca5a clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3faea5a)
#25 0x000055777a45086f clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fc286f)
#26 0x000055777a4b4ab9 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4026ab9)
#27 0x000055777a4afa45 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4021a45)
#28 0x000055777a4b0618 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4022618)
#29 0x000055777a4b9523 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#30 0x000055777b2f8846 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#31 0x000055777b2e8d70 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e5ad70)
#32 0x000055777c7f2b94 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6364b94)
#33 0x000055777b2f5608 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e67608)
#34 0x000055777ab4b5b9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46bd5b9)
#35 0x000055777aacfa86 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4641a86)
#36 0x000055777ac2e016 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47a0016)
#37 0x000055777755d4ad cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10cf4ad)
#38 0x00005577775591aa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#39 0x000055777a93794d 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
#40 0x0000557779fee030 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b60030)
#41 0x000055777a937f6f 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
#42 0x000055777a8ff69c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x447169c)
#43 0x000055777a90012d 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+++0x447212d)
#44 0x000055777a90820d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x447a20d)
#45 0x000055777755b70a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10cd70a)
#46 0x0000557777462245 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xfd4245)
#47 0x00007f5b321ba083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#48 0x0000557777553f8e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10c5f8e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-codegen

llvmbot commented 1 year ago

@llvm/issue-subscribers-c