Skip to content

Commit aac7099

Browse files
Merge pull request #4164 from adrian-prantl/circular-metadata
Limit the number of base classesbeing visited in ForEachSuperClassTyp…
2 parents 7850acd + 7aec57e commit aac7099

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,14 @@ class TargetReflectionContext
274274
LLDBTypeInfoProvider *tip, lldb::addr_t pointer,
275275
std::function<bool(SwiftLanguageRuntimeImpl::SuperClassType)> fn)
276276
override {
277+
// Guard against faulty self-referential metadata.
278+
unsigned limit = 256;
277279
auto md_ptr = m_reflection_ctx.readMetadataFromInstance(pointer);
278280
if (!md_ptr)
279281
return false;
280282

281283
// Class object.
282-
while (md_ptr && *md_ptr) {
284+
while (md_ptr && *md_ptr && --limit) {
283285
// Reading metadata is potentially expensive since (in a remote
284286
// debugging scenario it may even incur network traffic) so we
285287
// just return closures that the caller can use to query details

0 commit comments

Comments
 (0)