Skip to content

Commit a6be181

Browse files
committed
Don't trust the external cache when looking for field descriptors
When looking for field descriptors for a typeref, we should iterate over every image info available, even those that the cache claimed to have processed, as a last ditch effort. rdar://114567246
1 parent bbd6684 commit a6be181

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

stdlib/public/RemoteInspection/TypeRefBuilder.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,23 @@ RemoteRef<FieldDescriptor> TypeRefBuilder::getFieldTypeInfo(const TypeRef *TR) {
348348
}
349349
}
350350

351-
// On failure, fill out the cache, ReflectionInfo by ReflectionInfo,
352-
// until we find the field descriptor we're looking for.
351+
// If the heuristic didn't work, iterate over every reflection info
352+
// that the external cache hasn't processed.
353353
for (size_t i = 0; i < ReflectionInfos.size(); ++i) {
354354
if (ExternalTypeRefCache && ExternalTypeRefCache->isReflectionInfoCached(i))
355355
continue;
356356
if (auto FD = findFieldDescriptorAtIndex(i, *MangledName))
357357
return *FD;
358358
}
359359

360+
// If we still haven't found the field descriptor go over every reflection
361+
// info, even the ones the external cache supposedly processed.
362+
// TODO: if we find the field descriptor here there is a bug somewhere (most
363+
// likely on the external cache). Log this somehow.
364+
for (size_t i = 0; i < ReflectionInfos.size(); ++i)
365+
if (auto FD = findFieldDescriptorAtIndex(i, *MangledName))
366+
return *FD;
367+
360368
return nullptr;
361369
}
362370

0 commit comments

Comments
 (0)