From 4ea16835ba66f2240d050ffcaee44cee6c97cab9 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 26 Jun 2017 20:33:45 +0000 Subject: Vendor import of lld trunk r306325: https://llvm.org/svn/llvm-project/lld/trunk@306325 --- COFF/Strings.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'COFF/Strings.cpp') diff --git a/COFF/Strings.cpp b/COFF/Strings.cpp index d0558413f673..84f9b9a55a32 100644 --- a/COFF/Strings.cpp +++ b/COFF/Strings.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "Strings.h" +#include #if defined(_MSC_VER) #include @@ -21,6 +22,10 @@ using namespace llvm; Optional 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 Lock(Mu); + char Buf[4096]; if (S.startswith("?")) if (size_t Len = UnDecorateSymbolName(S.str().c_str(), Buf, sizeof(Buf), 0)) -- cgit v1.3