Skip to content

Commit 77d6a49

Browse files
Merge pull request #4105 from adrian-prantl/90666943
[lldb] Unlock Swift scratch context before early return
2 parents bbad294 + b0435fd commit 77d6a49

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lldb/source/Target/Target.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,9 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
22962296
// thread) is holding a read lock to the scratch context and
22972297
// replacing it could cause a use-after-free later on.
22982298
if (GetSwiftScratchContextLock().try_lock()) {
2299+
auto unlock = llvm::make_scope_exit([this] {
2300+
GetSwiftScratchContextLock().unlock();
2301+
});
22992302
if (m_use_scratch_typesystem_per_module)
23002303
DisplayFallbackSwiftContextErrors(swift_ast_ctx);
23012304
else if (StreamSP errs = GetDebugger().GetAsyncErrorStream()) {
@@ -2345,7 +2348,6 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
23452348
llvm::make_error<llvm::StringError>("DIAF", llvm::inconvertibleErrorCode());
23462349
}
23472350
}
2348-
GetSwiftScratchContextLock().unlock();
23492351
}
23502352
}
23512353
} else if (create_on_demand) {

0 commit comments

Comments
 (0)