-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] Crash in mangleUnqualifiedName
#106182
Labels
c++23
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
confirmed
Verified by a second party
crash-on-valid
regression:19
Regression in 19 release
Comments
github-actions
bot
added
the
clang
Clang issues not falling into any other category
label
Aug 27, 2024
Endilll
added
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
confirmed
Verified by a second party
regression:19
Regression in 19 release
and removed
clang
Clang issues not falling into any other category
regression
labels
Aug 27, 2024
@llvm/issue-subscribers-clang-frontend Author: Gene (gbresearch)
The following code fails with code 139:
```
template<class Base, template<class...> class S>
inline auto create_unique(auto&&... args) -> std::unique_ptr<Base>
requires(std::derived_from<std::remove_cvref_t<decltype(S{std::forward<decltype(args)>(args)...})>, Base>)
{
using Type = std::remove_cvref_t<decltype(S{std::forward<decltype(args)>(args)...})>;
return std::make_unique<Type>(std::forward<decltype(args)>(args)...);
}
```
removing constraint, code compiles. Full [demo](https://gcc.godbolt.org/z/5esrWsETT) in Code Explorer,
|
Endilll
changed the title
[clang] error: clang frontend command failed with exit code 139
[clang] Crash in Aug 27, 2024
mangleUnqualifiedName
Assertion: clang++: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578:
decltype(auto) llvm::cast(From*) [with To = clang::TagDecl; From = const clang::NamedDecl]:
Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' 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. <eof> parser at end of file
2. <source>:26:5: LLVM IR generation of declaration 'main'
3. <source>:26:5: Generating code for declaration 'main'
4. <source>:6:13: Mangling declaration 'create_unique'
#0 0x0000000003b123c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b123c8)
#1 0x0000000003b100bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b100bc)
#2 0x0000000003a58af8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000787027042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007870270969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000787027042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007870270287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000078702702871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000787027039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000007b58439 (anonymous namespace)::CXXNameMangler::mangleUnqualifiedName(clang::GlobalDecl, clang::DeclarationName, clang::DeclContext const*, unsigned int, llvm::SmallVector<llvm::StringRef, 4u> const*) (.constprop.0) ItaniumMangle.cpp:0:0
#10 0x0000000007b5a8de (anonymous namespace)::CXXNameMangler::mangleNameWithAbiTags(clang::GlobalDecl, llvm::SmallVector<llvm::StringRef, 4u> const*) ItaniumMangle.cpp:0:0
#11 0x0000000007b5b4ca (anonymous namespace)::CXXNameMangler::mangleName(clang::GlobalDecl) ItaniumMangle.cpp:0:0
#12 0x0000000007b5dcd6 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) ItaniumMangle.cpp:0:0
#13 0x0000000007b6c723 (anonymous namespace)::CXXNameMangler::mangleExpression(clang::Expr const*, unsigned int, bool) ItaniumMangle.cpp:0:0
#14 0x0000000007b5e50f (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) ItaniumMangle.cpp:0:0
#15 0x0000000007b7c3f8 (anonymous namespace)::CXXNameMangler::mangleTemplateArg(clang::TemplateArgument, bool) ItaniumMangle.cpp:0:0
#16 0x0000000007b7b193 (anonymous namespace)::CXXNameMangler::mangleTemplateArgs(clang::TemplateName, llvm::ArrayRef<clang::TemplateArgument>) ItaniumMangle.cpp:0:0
#17 0x0000000007b7d11f (anonymous namespace)::CXXNameMangler::manglePrefix(clang::NestedNameSpecifier*) ItaniumMangle.cpp:0:0
#18 0x0000000007b5e0d9 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) ItaniumMangle.cpp:0:0
#19 0x0000000007b7c3f8 (anonymous namespace)::CXXNameMangler::mangleTemplateArg(clang::TemplateArgument, bool) ItaniumMangle.cpp:0:0
#20 0x0000000007b7e2e3 (anonymous namespace)::CXXNameMangler::mangleUnresolvedName(clang::NestedNameSpecifier*, clang::DeclarationName, clang::TemplateArgumentLoc const*, unsigned int, unsigned int) ItaniumMangle.cpp:0:0
#21 0x0000000007b6e112 (anonymous namespace)::CXXNameMangler::mangleExpression(clang::Expr const*, unsigned int, bool) ItaniumMangle.cpp:0:0
#22 0x0000000007b7127b (anonymous namespace)::CXXNameMangler::mangleBareFunctionType(clang::FunctionProtoType const*, bool, clang::FunctionDecl const*) ItaniumMangle.cpp:0:0
#23 0x0000000007b72751 (anonymous namespace)::CXXNameMangler::mangleFunctionEncoding(clang::GlobalDecl) ItaniumMangle.cpp:0:0
#24 0x0000000007b766ae (anonymous namespace)::ItaniumMangleContextImpl::mangleCXXName(clang::GlobalDecl, llvm::raw_ostream&) ItaniumMangle.cpp:0:0
#25 0x0000000007b9b1f3 clang::MangleContext::mangleName(clang::GlobalDecl, llvm::raw_ostream&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7b9b1f3)
#26 0x0000000003f0fafc getMangledNameImpl(clang::CodeGen::CodeGenModule&, clang::GlobalDecl, clang::NamedDecl const*, bool) CodeGenModule.cpp:0:0
#27 0x0000000003f2173d clang::CodeGen::CodeGenModule::getMangledName(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f2173d)
#28 0x0000000003f57f61 clang::CodeGen::CodeGenModule::GetAddrOfFunction(clang::GlobalDecl, llvm::Type*, bool, bool, clang::CodeGen::ForDefinition_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f57f61)
#29 0x000000000428580e clang::CodeGen::CodeGenModule::getRawFunctionPointer(clang::GlobalDecl, llvm::Type*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x428580e)
#30 0x0000000004290b74 EmitDirectCallee(clang::CodeGen::CodeGenFunction&, clang::GlobalDecl) CGExpr.cpp:0:0
#31 0x00000000042b17b9 clang::CodeGen::CodeGenFunction::EmitCallee(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42b17b9)
#32 0x00000000042b1767 clang::CodeGen::CodeGenFunction::EmitCallee(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42b1767)
#33 0x00000000042b1d85 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42b1d85)
#34 0x00000000042b3d95 clang::CodeGen::RValue llvm::function_ref<clang::CodeGen::RValue (clang::CodeGen::ReturnValueSlot)>::callback_fn<(anonymous namespace)::AggExprEmitter::VisitCallExpr(clang::CallExpr const*)::'lambda'(clang::CodeGen::ReturnValueSlot)>(long, clang::CodeGen::ReturnValueSlot) CGExprAgg.cpp:0:0
#35 0x00000000042b977a (anonymous namespace)::AggExprEmitter::withReturnValueSlot(clang::Expr const*, llvm::function_ref<clang::CodeGen::RValue (clang::CodeGen::ReturnValueSlot)>) CGExprAgg.cpp:0:0
#36 0x00000000042b9f55 (anonymous namespace)::AggExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprAgg.cpp:0:0
#37 0x00000000042bc2d1 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#38 0x00000000042c4868 (anonymous namespace)::AggExprEmitter::VisitCXXBindTemporaryExpr(clang::CXXBindTemporaryExpr*) CGExprAgg.cpp:0:0
#39 0x00000000042bc6f3 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#40 0x00000000042bc4af (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#41 0x00000000042bcf5c clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42bcf5c)
#42 0x0000000004288cc1 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4288cc1)
#43 0x00000000042adcdd clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42adcdd)
#44 0x0000000003e727c5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e727c5)
#45 0x0000000003e7a4e4 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e7a4e4)
#46 0x0000000003ee1c74 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ee1c74)
#47 0x0000000003ef6b3f clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ef6b3f)
#48 0x0000000003f5843a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f5843a)
#49 0x0000000003f52f95 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f52f95)
#50 0x0000000003f5354b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f5354b)
#51 0x0000000003f5d953 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#52 0x000000000442ca36 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#53 0x000000000441cbb8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x441cbb8)
#54 0x0000000006534ad4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6534ad4)
#55 0x000000000442a558 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x442a558)
#56 0x00000000046b9999 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46b9999)
#57 0x000000000463cf8e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x463cf8e)
#58 0x00000000047a31de clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47a31de)
#59 0x0000000000ca71af cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xca71af)
#60 0x0000000000ca03fa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#61 0x000000000446d7f9 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
#62 0x0000000003a58fa4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a58fa4)
#63 0x000000000446ddef 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
#64 0x0000000004433da5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4433da5)
#65 0x000000000443480d 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+++0x443480d)
#66 0x000000000443c445 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x443c445)
#67 0x0000000000ca45a5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xca45a5)
#68 0x0000000000b78974 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb78974)
#69 0x0000787027029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#70 0x0000787027029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#71 0x0000000000c9feae _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc9feae)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134 |
mizvekov
added a commit
that referenced
this issue
Aug 28, 2024
As agreed on itanium-cxx-abi/cxx-abi#109 these placeholders should be mangled as a `template-prefix` production. ``` <template-prefix> ::= <template unqualified-name> # global template ::= <prefix> <template unqualified-name> # nested template ::= <template-param> # template template parameter ::= <substitution> ``` Previous to this patch, the template template parameter case was not handled, and template template parameters were incorrectly being handled as unqualified-names. Before #95202, DeducedTemplateType was not canonicalized correctly, so that template template parameter declarations were retained uncanonicalized. After #95202 patch, we correctly canonicalize them, but now this leads to handling these TTPs as anonymous entities, where the implementation correctly doesn't expect an anonymous declaration of this kind, leading to a crash. Fixes #106182.
mizvekov
added a commit
that referenced
this issue
Aug 28, 2024
As agreed on itanium-cxx-abi/cxx-abi#109 these placeholders should be mangled as a `template-prefix` production. ``` <template-prefix> ::= <template unqualified-name> # global template ::= <prefix> <template unqualified-name> # nested template ::= <template-param> # template template parameter ::= <substitution> ``` Previous to this patch, the template template parameter case was not handled, and template template parameters were incorrectly being handled as unqualified-names. Before #95202, DeducedTemplateType was not canonicalized correctly, so that template template parameter declarations were retained uncanonicalized. After #95202 patch, we correctly canonicalize them, but now this leads to handling these TTPs as anonymous entities, where the implementation correctly doesn't expect an anonymous declaration of this kind, leading to a crash. Fixes #106182.
cor3ntin
added a commit
to cor3ntin/llvm-project
that referenced
this issue
Aug 29, 2024
…izationType (llvm#95202)" This reverts commit 2e1ad93. Reverting llvm#95202 in the 19.x branch Fixes llvm#106182 The change in llvm#95202 causes code to crash and there is no good way to backport a fix for that as there are ABI-impacting changes at play. Instead we revert llvm#95202 in the 19x branch, fixing the regression and preserving the 18.x behavior (which is GCC's behavior) llvm#106335 (comment)
tru
pushed a commit
to cor3ntin/llvm-project
that referenced
this issue
Sep 1, 2024
…izationType (llvm#95202)" This reverts commit 2e1ad93. Reverting llvm#95202 in the 19.x branch Fixes llvm#106182 The change in llvm#95202 causes code to crash and there is no good way to backport a fix for that as there are ABI-impacting changes at play. Instead we revert llvm#95202 in the 19x branch, fixing the regression and preserving the 18.x behavior (which is GCC's behavior) llvm#106335 (comment)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
c++23
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
confirmed
Verified by a second party
crash-on-valid
regression:19
Regression in 19 release
The following code fails with code 139:
removing constraint, code compiles. Full demo in Code Explorer,
The text was updated successfully, but these errors were encountered: