Issue |
120081
|
Summary |
clang crash on x86_64-linux-gnu: Assertion `isa<T>(CanonicalType)' failed
|
Labels |
clang
|
Assignees |
|
Reporter |
bi6c
|
Compiler Explorer: https://godbolt.org/z/qdx3o195o
```console
<source>:14:19: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'volatile void *' [-Wint-conversion]
14 | __atomic_clear (__ATOMIC_RELEASE, __ATOMIC_RELEASE);
| ^~~~~~~~~~~~~~~~
<built-in>:14:26: note: expanded from macro '__ATOMIC_RELEASE'
14 | #define __ATOMIC_RELEASE 3
| ^
clang: /root/llvm-project/clang/include/clang/AST/Type.h:8805: 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 -fno-verbose-asm -c --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <source>:18:1: current parser token 'int'
2. <source>:8:1: LLVM IR generation of declaration 'tf'
3. <source>:8:1: Generating code for declaration 'tf'
#0 0x0000000003c56df8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c56df8)
#1 0x0000000003c54b04 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c54b04)
#2 0x0000000003ba2068 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000078d6c8442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000078d6c84969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000078d6c8442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000078d6c84287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000078d6c842871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000078d6c8439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000041e3763 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41e3763)
#10 0x000000000437ec6a clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::GlobalDecl, unsigned int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x437ec6a)
#11 0x000000000446222e clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::CallBase**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x446222e)
#12 0x00000000044b9ae4 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#13 0x00000000044ae16b clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#14 0x00000000044b3dac clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44b3dac)
#15 0x000000000443c7fe clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x443c7fe)
#16 0x00000000044606d5 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44606d5)
#17 0x0000000003fc23b5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fc23b5)
#18 0x0000000003fca024 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fca024)
#19 0x0000000004032ff4 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4032ff4)
#20 0x0000000004045d38 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4045d38)
#21 0x00000000040adb4a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x40adb4a)
#22 0x00000000040a8dd5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x40a8dd5)
#23 0x00000000040a91bb clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x40a91bb)
#24 0x00000000040b3983 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#25 0x00000000045e2b06 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#26 0x00000000045d3688 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45d3688)
#27 0x00000000065ca1f4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x65ca1f4)
#28 0x00000000045e0668 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45e0668)
#29 0x0000000004899a89 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4899a89)
#30 0x000000000481c48e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x481c48e)
#31 0x00000000049862ce clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49862ce)
#32 0x0000000000ce1c7f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xce1c7f)
#33 0x0000000000cd971a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#34 0x0000000004624ad9 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
#35 0x0000000003ba2514 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ba2514)
#36 0x00000000046250cf 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
#37 0x00000000045ea3dd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45ea3dd)
#38 0x00000000045eb4cd 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+0x45eb4cd)
#39 0x00000000045f2a45 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45f2a45)
#40 0x0000000000cdeac3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcdeac3)
#41 0x0000000000bac364 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbac364)
#42 0x000078d6c8429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#43 0x000078d6c8429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#44 0x0000000000cd91c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcd91c5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
Code:
```c
#include <pthread.h>
#include <stdbool.h>
bool lock;
int counter;
void *
tf (void *arg)
{
(void) arg;
while (__atomic_test_and_set (&lock, __ATOMIC_ACQUIRE))
;
++counter;
__atomic_clear (__ATOMIC_RELEASE, __ATOMIC_RELEASE);
return (void *) 0;
}
int
main ()
{
pthread_t thr;
pthread_create (&thr, 0, tf, 0);
tf ((void *) 0);
pthread_join (thr, 0);
return 0;
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs