Skip to content

Commit e90fe50

Browse files
committed
Only delete the scratch context if we can acquire the unique lock
1 parent 6b89a2a commit e90fe50

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lldb/source/Target/Target.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,6 +2737,14 @@ llvm::Optional<SwiftScratchContextReader> Target::GetSwiftScratchContext(
27372737
DisplayFallbackSwiftContextErrors(cached_ast_ctx);
27382738
// Try again.
27392739
// FIXME: Shouldn't this continue rather than return?
2740+
auto &lock = GetSwiftScratchContextLock();
2741+
if (!lock.try_lock()) {
2742+
if (log)
2743+
log->Printf("module scratch context has errors but couldn't "
2744+
"acquire scratch context lock\n");
2745+
return;
2746+
}
2747+
std::lock_guard<std::shared_mutex> unlock(lock, std::adopt_lock);
27402748
m_scratch_typesystem_for_module.erase(key);
27412749
if (log)
27422750
log->Printf("erased module-wide scratch context with errors\n");

0 commit comments

Comments
 (0)