Skip to content

Commit 98bc304

Browse files
committed
[lld][COFF] Fix TypeServerSource lookup on GUID collisions
Microsoft shipped a bunch of PDB files with broken/invalid GUIDs which lead lld to use 0xFF as the key for these files in an internal cache. When multiple files have this key it will lead to collisions and confused symbol lookup. Several approaches to fix this was considered. Including making the key the path to the PDB file, but this requires some filesystem operations in order to normalize the file path. Since this only happens with malformatted PDB files and we haven't seen this before they malformatted files where shipped with visual studio we probably shouldn't optimize for this use-case. Instead we now just don't insert files with Guid == 0xFF into the cache map and warn if we get collisions so similar problems can be found in the future instead of being silent. Discussion about the root issue and the approach to this fix can be found on Github: llvm#54487 Reviewed By: aganea Differential Revision: https://reviews.llvm.org/D122372
1 parent 0d8df98 commit 98bc304

7 files changed

+2426
-2
lines changed

lld/COFF/DebugTypes.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,15 @@ class TypeServerSource : public TpiSource {
5656
return;
5757
Guid = expectedInfo->getGuid();
5858
auto it = ctx.typeServerSourceMappings.emplace(Guid, this);
59-
assert(it.second);
60-
(void)it;
59+
if (!it.second) {
60+
// If we hit here we have collision on Guid's in two PDB files.
61+
// This can happen if the PDB Guid is invalid or if we are really
62+
// unlucky. This should fall back on stright file-system lookup.
63+
TypeServerSource *tSrc = (TypeServerSource *)it.first->second;
64+
log("GUID collision between " + file.getFilePath() + " and " +
65+
tSrc->pdbInputFile->session->getPDBFile().getFilePath());
66+
ctx.typeServerSourceMappings.erase(Guid);
67+
}
6168
}
6269

6370
Error mergeDebugT(TypeMerger *m) override;

0 commit comments

Comments
 (0)