[Lldb-commits] [lldb] [lldb] Don't apply the MS inheritance model to non-CXXRecordDecl DWARF types (PR #216711)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 17 05:04:10 PDT 2026
https://github.com/robk-dev created https://github.com/llvm/llvm-project/pull/216711
`DWARFASTParserClang::CompleteRecordType` sets the Microsoft C++ ABI
inheritance model on records when the target uses that ABI. Objective-C
interfaces reach that code too, and `ObjCInterfaceDecl` is not a
`CXXRecordDecl`, so the cast asserted — every completion of an Objective-C type
from DWARF crashed LLDB on an MSVC target.
Only apply the inheritance model when the declaration really is a
`CXXRecordDecl`.
This is not specific to any Objective-C runtime: it is reachable by any DWARF
containing Objective-C types on a target using the Microsoft C++ ABI. It was
found while debugging Objective-C on Windows with the GNUstep runtime, where
it made every ObjC type unusable.
I have not included a regression test. Reproducing it needs DWARF containing
an Objective-C interface for a target whose C++ ABI is Microsoft, which the
existing `YAMLModuleTester`-based unit tests here do not currently set up, and
a Shell test would need an MSVC-target Objective-C binary. Happy to add either
if you have a preference — a unit test with a synthetic COFF module seems the
more portable of the two.
>From b710004006447348e3a9bf986a0a0a73669150ac Mon Sep 17 00:00:00 2001
From: Rob <robk at robk.dev>
Date: Wed, 12 Aug 2026 23:37:16 +0100
Subject: [PATCH] [lldb] Guard MS inheritance model against non-CXXRecordDecl
DWARF types
CompleteRecordType() computes the MSInheritanceAttr for the Microsoft
C++ ABI by calling calculateInheritanceModel() on the record's
CXXRecordDecl. Objective-C interface types complete through the same
path but are ObjCInterfaceDecls, so GetAsCXXRecordDecl() returns null
and the Microsoft-ABI block crashed on every Objective-C type
completion for *-windows-msvc targets. Guard it the same way as the
SetRecordLayout call above.
Found debugging GNUstep Objective-C programs on Windows, where any
`frame variable` touching an object type crashed LLDB.
Co-Authored-By: Claude Fable 5 <noreply at anthropic.com>
---
.../source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index b60f1d9e41958..24b5d73fd1d80 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2244,8 +2244,10 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
// DWARF doesn't have the attribute, but we can infer the value the same way
// as Clang Sema does. It's required to calculate the size of pointers to
- // member functions of this type.
- if (m_ast.getASTContext().getTargetInfo().getCXXABI().isMicrosoft()) {
+ // member functions of this type. Objective-C interface types reach this
+ // point too but are not CXXRecordDecls, so record_decl may be null here.
+ if (record_decl &&
+ m_ast.getASTContext().getTargetInfo().getCXXABI().isMicrosoft()) {
auto IM = record_decl->calculateInheritanceModel();
record_decl->addAttr(clang::MSInheritanceAttr::CreateImplicit(
m_ast.getASTContext(), true, {},
More information about the lldb-commits
mailing list