[sourcekitd] Fix a race in EditableTextBuffer::getSnapshot()

Found by TSan!

This was found while trying to reproduce a test failure on a linux bot
while running the test/Misc/stats.swift test.  Hopefully this was the
underlying issue.

rdar://35537968
This commit is contained in:
Ben Langmuir
2017-11-16 14:35:20 -08:00
parent b4f5a5806c
commit c58cc4ee39
2 changed files with 2 additions and 1 deletions

View File

@@ -126,6 +126,7 @@ EditableTextBuffer::EditableTextBuffer(StringRef Filename, StringRef Text) {
}
ImmutableTextSnapshotRef EditableTextBuffer::getSnapshot() const {
llvm::sys::ScopedLock L(EditMtx);
return new ImmutableTextSnapshot(const_cast<EditableTextBuffer*>(this), Root,
CurrUpd);
}