-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Initially reported by CI:
https://github.com/ClangBuiltLinux/continuous-integration2/actions/runs/16568941022
After commit 535c445eb94c ("drm/xe: Add dependency scheduler for GT TLB invalidations to bind queues") in linux-next, there is a crash when building certain files under drivers/gpu/drm/xe.
$ make -skj"$(nproc)" ARCH=x86_64 LLVM=1 mrproper allmodconfig drivers/gpu/drm/xe/xe_ring_ops.o
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: .../toolchains/llvm/19.1.7/bin/clang ... -o drivers/gpu/drm/xe/xe_ring_ops.o drivers/gpu/drm/xe/xe_ring_ops.c
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. drivers/gpu/drm/xe/xe_ring_ops.c:429:13: Generating code for declaration 'emit_job_gen12_gsc'
#0 0x00005589bf76f6b5 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) Signals.cpp:0:0
#1 0x00005589bf76f48e llvm::sys::CleanupOnSignal(unsigned long) (clang+0x516f48e)
#2 0x00005589bf73ca3e (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
#3 0x00005589bf73cbbe CrashRecoverySignalHandler(int) (.llvm.3151160796388693759) CrashRecoveryContext.cpp:0:0
#4 0x00007fb660c4def0 (/usr/lib/libc.so.6+0x3def0)
#5 0x00005589c1ab8353 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (clang+0x74b8353)
#6 0x00005589bf892a7a getFieldOffsetInBits(clang::CodeGen::CodeGenFunction&, clang::RecordDecl const*, clang::FieldDecl const*, long&) CGExpr.cpp:0:0
#7 0x00005589bf892adc getFieldOffsetInBits(clang::CodeGen::CodeGenFunction&, clang::RecordDecl const*, clang::FieldDecl const*, long&) CGExpr.cpp:0:0
#8 0x00005589bf892adc getFieldOffsetInBits(clang::CodeGen::CodeGenFunction&, clang::RecordDecl const*, clang::FieldDecl const*, long&) CGExpr.cpp:0:0
#9 0x00005589bf88f64e getOffsetDifferenceInBits(clang::CodeGen::CodeGenFunction&, clang::FieldDecl const*, clang::FieldDecl const*) CGExpr.cpp:0:0
#10 0x00005589c2956102 clang::CodeGen::CodeGenFunction::EmitArraySubscriptExpr(clang::ArraySubscriptExpr const*, bool) (.cold.0) bolt-pseudo.o:0:0
#11 0x00005589c296b22e clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) (.cold.0) bolt-pseudo.o:0:0
#12 0x00005589c1bcc340 (anonymous namespace)::ScalarExprEmitter::EmitLoadOfLValue(clang::Expr const*) CGExprScalar.cpp:0:0
#13 0x00005589c1bcd909 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#14 0x00005589c1bcc951 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (clang+0x75cc951)
#15 0x00005589c1bc9aba clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* const, clang::Stmt const* const>>, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder) (clang+0x75c9aba)
#16 0x00005589c17fb6c0 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (clang+0x71fb6c0)
#17 0x00005589c1bce82f clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) (.llvm.6574167205783130985) CGExprScalar.cpp:0:0
#18 0x00005589c1bcc951 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (clang+0x75cc951)
#19 0x00005589c1bd9a29 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (clang+0x75d9a29)
#20 0x00005589c1bd9544 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (clang+0x75d9544)
#21 0x00005589c17ff276 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (clang+0x71ff276)
#22 0x00005589c17f08bc clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) CodeGenModule.cpp:0:0
#23 0x00005589c17f486b clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) CodeGenModule.cpp:0:0
#24 0x00005589c17f46ab clang::CodeGen::CodeGenModule::EmitDeferred() CodeGenModule.cpp:0:0
#25 0x00005589c17f46d3 clang::CodeGen::CodeGenModule::EmitDeferred() CodeGenModule.cpp:0:0
#26 0x00005589c1f3bcb3 clang::CodeGen::CodeGenModule::Release() (clang+0x793bcb3)
#27 0x00005589c1f3eaab (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) (.llvm.14836813337269125783) ModuleBuilder.cpp:0:0
#28 0x00005589c1f3ec0e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#29 0x00005589c170b808 clang::ParseAST(clang::Sema&, bool, bool) (clang+0x710b808)
#30 0x00005589c1fe2fbe clang::FrontendAction::Execute() (clang+0x79e2fbe)
#31 0x00005589c1fe586d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (clang+0x79e586d)
#32 0x00005589c1fe5656 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (clang+0x79e5656)
#33 0x00005589c2064ef4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (clang+0x7a64ef4)
#34 0x00005589c2067f80 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#35 0x00005589c2067e2d 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::$_0>(long) Job.cpp:0:0
#36 0x00005589c2067e04 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (clang+0x7a67e04)
#37 0x00005589c2067ca9 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (clang+0x7a67ca9)
#38 0x00005589c2067b19 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (clang+0x7a67b19)
#39 0x00005589c20676f8 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (clang+0x7a676f8)
#40 0x00005589c2067047 clang_main(int, char**, llvm::ToolContext const&) (clang+0x7a67047)
#41 0x00005589c2066512 main (clang+0x7a66512)
#42 0x00007fb660c376b5 (/usr/lib/libc.so.6+0x276b5)
#43 0x00007fb660c37769 __libc_start_main (/usr/lib/libc.so.6+0x27769)
#44 0x00005589c1f71e44 _start (clang+0x7971e44)
A build with assertions enabled shows:
clang: clang/lib/AST/RecordLayoutBuilder.cpp:3335: const ASTRecordLayout &clang::ASTContext::getASTRecordLayout(const RecordDecl *) const: Assertion `D && "Cannot get layout of forward declarations!"' failed.
LLVM 20 does not crash, so I reverse bisected to llvm/llvm-project@160fb11 (cc @bwendling) as the fix for this crash in LLVM. I went back to the final landed version of __counted_by in LLVM 18 (llvm/llvm-project@00b6d03) and modified Linux to allow use of __counted_by (since f06e108a3dc53c0f5234d18de0bd224753db5019 made LLVM 19.1.3 a hard requirement for __counted_by) and it still fails (somewhat expectedly).
Is there a way to avoid this by modifying the code added by the -next change above? Or should we require LLVM 20.1.0 or newer for __counted_by?
cc @kees