Skip to content

Don't trust the external cache when looking for field descriptors #68638

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions stdlib/public/RemoteInspection/TypeRefBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,23 @@ RemoteRef<FieldDescriptor> TypeRefBuilder::getFieldTypeInfo(const TypeRef *TR) {
}
}

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

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

return nullptr;
}

Expand Down