diff options
Diffstat (limited to 'COFF/Strings.cpp')
-rw-r--r-- | COFF/Strings.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/COFF/Strings.cpp b/COFF/Strings.cpp index d0558413f6733..84f9b9a55a32a 100644 --- a/COFF/Strings.cpp +++ b/COFF/Strings.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "Strings.h" +#include <mutex> #if defined(_MSC_VER) #include <Windows.h> @@ -21,6 +22,10 @@ using namespace llvm; Optional<std::string> coff::demangle(StringRef S) { #if defined(_MSC_VER) + // UnDecorateSymbolName is not thread-safe, so we need a mutex. + static std::mutex Mu; + std::lock_guard<std::mutex> Lock(Mu); + char Buf[4096]; if (S.startswith("?")) if (size_t Len = UnDecorateSymbolName(S.str().c_str(), Buf, sizeof(Buf), 0)) |