Closed fordfrog closed 1 month ago
@llvm/issue-subscribers-clang-codegen
Author: Miroslav Šulc (fordfrog)
Confirmed on trunk: https://godbolt.org/z/5scqd8KWo Reduced by me and C-Reduce:
struct BasicPersistent {
BasicPersistent(const char * = __builtin_FUNCTION());
};
BasicPersistent& declval();
template <typename... _Args>
auto construct_at(_Args &&...) -> decltype(new BasicPersistent()) {}
struct CFXJSE_Engine {
void AddObjectToUpArray();
};
void CFXJSE_Engine::AddObjectToUpArray() {
construct_at();
}
Clang 19.0 crash:
<source>:8:44: warning: expression with side effects has no effect in an unevaluated context [-Wunevaluated-expression]
8 | auto construct_at(_Args &&...) -> decltype(new BasicPersistent()) {}
| ^
<source>:8:68: warning: non-void function does not return a value [-Wreturn-type]
8 | auto construct_at(_Args &&...) -> decltype(new BasicPersistent()) {}
| ^
<source>:15:3: note: in instantiation of function template specialization 'construct_at<>' requested here
15 | construct_at();
| ^
clang++: /root/build/tools/clang/include/clang/AST/TypeNodes.inc:39:
clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type*) const:
Assertion `!T->isDependentType() && "should not see dependent types here"' 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 -std=c++11 <source>
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. <source>:8:6: Generating code for declaration 'construct_at'
#0 0x0000000003a385c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a385c8)
#1 0x0000000003a362bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a362bc)
#2 0x0000000003980688 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007b3446e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007b3446e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007b3446e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007b3446e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007b3446e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007b3446e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000074c045a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74c045a)
#10 0x00000000074a7cd7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74a7cd7)
#11 0x00000000074bf0f7 clang::ASTContext::getTypeAlignInChars(clang::QualType) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74bf0f7)
#12 0x000000000419529a clang::CodeGen::CodeGenFunction::CreateIRTemp(clang::QualType, llvm::Twine const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x419529a)
#13 0x0000000003e0e24c clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e0e24c)
#14 0x0000000003e13817 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e13817)
#15 0x0000000003e73352 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e73352)
#16 0x0000000003e6e315 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e6e315)
#17 0x0000000003e79a7d clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e79a7d)
#18 0x0000000003e7c473 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e7c473)
#19 0x000000000432842e (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#20 0x0000000004326075 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4326075)
#21 0x00000000063bef8c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63bef8c)
#22 0x0000000004326808 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4326808)
#23 0x00000000045ad759 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45ad759)
#24 0x000000000453336e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453336e)
#25 0x0000000004695bae clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4695bae)
#26 0x0000000000c710c5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc710c5)
#27 0x0000000000c6a2ea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x0000000004369f39 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 0x0000000003980b34 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3980b34)
#30 0x000000000436a52f 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 0x000000000432ffc5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x432ffc5)
#32 0x0000000004330a2d 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+++0x4330a2d)
#33 0x0000000004338435 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4338435)
#34 0x0000000000c6e495 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc6e495)
#35 0x0000000000b46364 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb46364)
#36 0x00007b3446e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#37 0x00007b3446e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#38 0x0000000000c69d9e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc69d9e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
@llvm/issue-subscribers-c-11
Author: Miroslav Šulc (fordfrog)
I got two more crashes out of this reproducer. I'll reduce them as well, and file separate issues for them.
I am facing the same issue. Is there any way to fix this?
It looks like this was a clang-18 regression: https://godbolt.org/z/vfo1rExah
But the error message in OP shows llvm / clang 19 and i am also using version 19.
But the error message in OP shows llvm / clang 19 and i am also using version 19.
Yes but the crash started happening in clang-18.
i also face the same issue when compiling llvm (currently version 20.0.0_pre20240830) with both llvm 20.0.0_pre20240822 and 19.1.0_rc3. llvm 18.1.8 does not crash though. llvm.zip
@fordfrog For some reason Gentoo has enabled debug
on LLVM / Clang by default. I've got around this error by disabling it.
@fordfrog For some reason Gentoo has enabled
debug
on LLVM / Clang by default. I've got around this error by disabling it.
oh thanks, disabling debug
made me evade this issue too.
@Endilll @shafik Looks like this no longer crashes on trunk (or 19.1); I think we can close this now?
it's on gentoo linux, compiling ungoogled-chromium. i hope all needed information is included. in case something more is needed, please let me know. i have this issue for quite a long time already.
files.zip