Skip to content

Commit

Permalink
[lld][COFF] Fix TypeServerSource lookup on GUID collisions
Browse files Browse the repository at this point in the history
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: #54487

Reviewed By: aganea

Differential Revision: https://reviews.llvm.org/D122372
  • Loading branch information
tru committed Apr 2, 2022
1 parent 0d8df98 commit 98bc304
Show file tree
Hide file tree
Showing 7 changed files with 2,426 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lld/COFF/DebugTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,15 @@ class TypeServerSource : public TpiSource {
return;
Guid = expectedInfo->getGuid();
auto it = ctx.typeServerSourceMappings.emplace(Guid, this);
assert(it.second);
(void)it;
if (!it.second) {
// If we hit here we have collision on Guid's in two PDB files.
// This can happen if the PDB Guid is invalid or if we are really
// unlucky. This should fall back on stright file-system lookup.
TypeServerSource *tSrc = (TypeServerSource *)it.first->second;
log("GUID collision between " + file.getFilePath() + " and " +
tSrc->pdbInputFile->session->getPDBFile().getFilePath());
ctx.typeServerSourceMappings.erase(Guid);
}
}

Error mergeDebugT(TypeMerger *m) override;
Expand Down
Loading

0 comments on commit 98bc304

Please sign in to comment.