Skip to content
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
15 changes: 12 additions & 3 deletions src/DotNet/Pdb/PdbState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ PdbDocument Add_NoLock(PdbDocument doc) {
}

PdbDocument Add_NoLock(SymbolDocument symDoc) {
// A document read from a Portable PDB is identified by its Document row. Look it up by
// token first, so that editing its Url after loading doesn't make the lazy lookup from
// AddSequencePoints miss it and add the same row a second time (see #566).
if (symDoc.MDToken.HasValue && tokenToDocument.TryGetValue(symDoc.MDToken.Value, out var existing))
return existing;
var doc = PdbDocument.CreatePartialForCompare(symDoc);
if (docDict.TryGetValue(doc, out var orig))
return orig;
Expand All @@ -150,9 +155,13 @@ public bool Remove(PdbDocument doc) {
#if THREAD_SAFE
theLock.EnterWriteLock(); try {
#endif
if (doc.MDToken.HasValue)
tokenToDocument.Remove(doc.MDToken.Value);
return docDict.Remove(doc);
// doc may be an equal copy of the stored document, so remove the stored document's token
if (!docDict.TryGetValue(doc, out var stored))
return false;
docDict.Remove(doc);
if (stored.MDToken.HasValue)
tokenToDocument.Remove(stored.MDToken.Value);
return true;
#if THREAD_SAFE
} finally { theLock.ExitWriteLock(); }
#endif
Expand Down
Loading