Skip to content

Commit

Permalink
[Support] Fix Windows dump file hang with multi-threaded crashes
Browse files Browse the repository at this point in the history
Prevents deadlock between MiniDumpWriteDump and
CryptAcquireContextW (called via fs::createTemporaryFile) in
WriteWindowsDumpFile.

However, there's no guarantee that deadlock can't still occur between
MiniDumpWriteDump and some other Win32 API call. But that would appear
to be the "accepted" risk of using MiniDumpWriteDump in this manner.

Differential Revision: https://reviews.llvm.org/D129004
  • Loading branch information
nga888 committed Jul 8, 2022
1 parent 1d27f26 commit 86a2f2e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llvm/lib/Support/Windows/Signals.inc
Expand Up @@ -731,6 +731,11 @@ static bool GetDumpType(HKEY Key, MINIDUMP_TYPE &ResultType) {
/// otherwise.
static std::error_code WINAPI
WriteWindowsDumpFile(PMINIDUMP_EXCEPTION_INFORMATION ExceptionInfo) {
struct ScopedCriticalSection {
ScopedCriticalSection() { EnterCriticalSection(&CriticalSection); }
~ScopedCriticalSection() { LeaveCriticalSection(&CriticalSection); }
} SCS;

using namespace llvm;
using namespace llvm::sys;

Expand Down

0 comments on commit 86a2f2e

Please sign in to comment.