Open kadircet opened 2 months ago
@llvm/issue-subscribers-clang-frontend
Author: kadir çetinkaya (kadircet)
Looks like a clang-18 regression since this does not crash on clang-17: https://godbolt.org/z/4MfKj1G7n
Assertion:
clang++: /root/llvm-project/clang/include/clang/AST/Type.h:957:
const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const:
Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
Backtrace:
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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++23 <source>
1. <source>:7:18: current parser token ';'
#0 0x0000000003ade538 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ade538)
#1 0x0000000003adc22c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3adc22c)
#2 0x0000000003a25208 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000072aa28842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000072aa288969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000072aa28842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000072aa288287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000072aa2882871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000072aa28839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000078d6178 EvaluateInPlace(clang::APValue&, (anonymous namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr const*, bool) ExprConstant.cpp:0:0
#10 0x00000000079125b3 clang::Expr::EvaluateAsInitializer(clang::APValue&, clang::ASTContext const&, clang::VarDecl const*, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x79125b3)
#11 0x00000000077e7082 clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x77e7082)
#12 0x00000000077e73d1 clang::VarDecl::checkForConstantInitialization(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x77e73d1)
#13 0x000000000689940e clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x689940e)
#14 0x000000000689fdba clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x689fdba)
#15 0x0000000006530609 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6530609)
#16 0x000000000653eeea clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x653eeea)
#17 0x00000000064fe5ee clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64fe5ee)
#18 0x00000000064fed9e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64fed9e)
#19 0x0000000006505417 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6505417)
#20 0x00000000065062ed clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65062ed)
#21 0x00000000064f978a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64f978a)
#22 0x00000000043f3508 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43f3508)
#23 0x000000000467fe69 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x467fe69)
#24 0x000000000460439e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x460439e)
#25 0x000000000476929e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x476929e)
#26 0x0000000000c927ef cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc927ef)
#27 0x0000000000c8ba3a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x0000000004436b79 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
#29 0x0000000003a256b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a256b4)
#30 0x000000000443716f 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
#31 0x00000000043fcd05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43fcd05)
#32 0x00000000043fd76d 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+++0x43fd76d)
#33 0x0000000004405385 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4405385)
#34 0x0000000000c8fbe5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc8fbe5)
#35 0x0000000000b634c4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb634c4)
#36 0x000072aa28829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#37 0x000072aa28829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#38 0x0000000000c8b4ee _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc8b4ee)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
I've never worked on clang's frontend, but I'm happy to take a look and try to fix the crash if it's open. :)
I've never worked on clang's frontend, but I'm happy to take a look and try to fix the crash if it's open. :)
Since this looks like a regression, a git bisect: https://llvm.org/docs/GitBisecting.html
probably makes the most sense, if we can narrow it down to a commit then usually we can tag in the author of the commit to help debug the problem.
$ cat preprocessed.cc