Author: zturner Date: Tue Feb 28 14:29:20 2017 New Revision: 296516 URL: http://llvm.org/viewvc/llvm-project?rev=296516&view=rev Log: Wrap the call to UndecorateSymbolName in a mutex.
MSDN documents that this function is not thread-safe, so we wrap it in a global mutex. Modified: lldb/trunk/source/Core/Mangled.cpp Modified: lldb/trunk/source/Core/Mangled.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=296516&r1=296515&r2=296516&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Tue Feb 28 14:29:20 2017 @@ -41,6 +41,24 @@ using namespace lldb_private; +#if defined(_MSC_VER) +static DWORD safeUndecorateName(const char* Mangled, char *Demangled, DWORD DemangledLength) { + static std::mutex M; + std::lock_guard<std::mutex> Lock(M); + return ::UnDecorateSymbolName( + Mangled, Demangled, DemangledLength, + UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected + // keywords + UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, + // etc keywords + UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications + UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc + // specifiers + UNDNAME_NO_MS_KEYWORDS // Strip all MS extension keywords + ); +} +#endif + static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) { if (s) { if (s[0] == '?') @@ -253,17 +271,7 @@ Mangled::GetDemangledName(lldb::Language const size_t demangled_length = 2048; demangled_name = static_cast<char *>(::malloc(demangled_length)); ::ZeroMemory(demangled_name, demangled_length); - DWORD result = ::UnDecorateSymbolName( - mangled_name, demangled_name, demangled_length, - UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected - // keywords - UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, - // etc keywords - UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications - UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc - // specifiers - UNDNAME_NO_MS_KEYWORDS // Strip all MS extension keywords - ); + DWORD result = safeUndecorateName(mangled_name, demangled_name, demangled_length); if (log) { if (demangled_name && demangled_name[0]) log->Printf("demangled msvc: %s -> \"%s\"", mangled_name, _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits