Fix crash caused by conflicting tracy DbgHelp lock helper names

This commit is contained in:
2025-04-19 11:38:11 +03:00
parent 9645008460
commit 7c5628d47e
2 changed files with 12 additions and 12 deletions

View File

@@ -42,17 +42,17 @@ void* WindowsPlatform::Instance = nullptr;
extern "C" { extern "C" {
static HANDLE dbgHelpLock; static HANDLE dbgHelpLock;
void DbgHelpInit() void FlaxDbgHelpInit()
{ {
dbgHelpLock = CreateMutexW(nullptr, FALSE, nullptr); dbgHelpLock = CreateMutexW(nullptr, FALSE, nullptr);
} }
void DbgHelpLock() void FlaxDbgHelpLock()
{ {
WaitForSingleObject(dbgHelpLock, INFINITE); WaitForSingleObject(dbgHelpLock, INFINITE);
} }
void DbgHelpUnlock() void FlaxDbgHelpUnlock()
{ {
ReleaseMutex(dbgHelpLock); ReleaseMutex(dbgHelpLock);
} }
@@ -544,7 +544,7 @@ void WindowsPlatform::PreInit(void* hInstance)
#if CRASH_LOG_ENABLE #if CRASH_LOG_ENABLE
TCHAR buffer[MAX_PATH] = { 0 }; TCHAR buffer[MAX_PATH] = { 0 };
DbgHelpLock(); FlaxDbgHelpLock();
if (::GetModuleFileNameW(::GetModuleHandleW(nullptr), buffer, MAX_PATH)) if (::GetModuleFileNameW(::GetModuleHandleW(nullptr), buffer, MAX_PATH))
SymbolsPath.Add(StringUtils::GetDirectoryName(buffer)); SymbolsPath.Add(StringUtils::GetDirectoryName(buffer));
if (::GetEnvironmentVariableW(TEXT("_NT_SYMBOL_PATH"), buffer, MAX_PATH)) if (::GetEnvironmentVariableW(TEXT("_NT_SYMBOL_PATH"), buffer, MAX_PATH))
@@ -553,7 +553,7 @@ void WindowsPlatform::PreInit(void* hInstance)
options |= SYMOPT_LOAD_LINES | SYMOPT_FAIL_CRITICAL_ERRORS | SYMOPT_DEFERRED_LOADS | SYMOPT_EXACT_SYMBOLS; options |= SYMOPT_LOAD_LINES | SYMOPT_FAIL_CRITICAL_ERRORS | SYMOPT_DEFERRED_LOADS | SYMOPT_EXACT_SYMBOLS;
SymSetOptions(options); SymSetOptions(options);
OnSymbolsPathModified(); OnSymbolsPathModified();
DbgHelpUnlock(); FlaxDbgHelpUnlock();
#endif #endif
GetWindowsVersion(WindowsName, VersionMajor, VersionMinor, VersionBuild); GetWindowsVersion(WindowsName, VersionMajor, VersionMinor, VersionBuild);
@@ -767,7 +767,7 @@ void WindowsPlatform::BeforeExit()
void WindowsPlatform::Exit() void WindowsPlatform::Exit()
{ {
#if CRASH_LOG_ENABLE #if CRASH_LOG_ENABLE
DbgHelpLock(); FlaxDbgHelpLock();
#if !TRACY_ENABLE #if !TRACY_ENABLE
if (SymInitialized) if (SymInitialized)
{ {
@@ -776,7 +776,7 @@ void WindowsPlatform::Exit()
} }
#endif #endif
SymbolsPath.Resize(0); SymbolsPath.Resize(0);
DbgHelpUnlock(); FlaxDbgHelpUnlock();
#endif #endif
// Unregister app class // Unregister app class
@@ -1278,14 +1278,14 @@ void* WindowsPlatform::LoadLibrary(const Char* filename)
#if CRASH_LOG_ENABLE #if CRASH_LOG_ENABLE
// Refresh modules info during next stack trace collecting to have valid debug symbols information // Refresh modules info during next stack trace collecting to have valid debug symbols information
DbgHelpLock(); FlaxDbgHelpLock();
if (folder.HasChars() && !SymbolsPath.Contains(folder)) if (folder.HasChars() && !SymbolsPath.Contains(folder))
{ {
SymbolsPath.Add(folder); SymbolsPath.Add(folder);
SymbolsPath.Last().Replace('/', '\\'); SymbolsPath.Last().Replace('/', '\\');
OnSymbolsPathModified(); OnSymbolsPathModified();
} }
DbgHelpUnlock(); FlaxDbgHelpUnlock();
#endif #endif
return handle; return handle;
@@ -1296,7 +1296,7 @@ void* WindowsPlatform::LoadLibrary(const Char* filename)
Array<PlatformBase::StackFrame> WindowsPlatform::GetStackFrames(int32 skipCount, int32 maxDepth, void* context) Array<PlatformBase::StackFrame> WindowsPlatform::GetStackFrames(int32 skipCount, int32 maxDepth, void* context)
{ {
Array<StackFrame> result; Array<StackFrame> result;
DbgHelpLock(); FlaxDbgHelpLock();
// Initialize // Initialize
HANDLE process = GetCurrentProcess(); HANDLE process = GetCurrentProcess();
@@ -1428,7 +1428,7 @@ Array<PlatformBase::StackFrame> WindowsPlatform::GetStackFrames(int32 skipCount,
} }
} }
DbgHelpUnlock(); FlaxDbgHelpUnlock();
return result; return result;
} }

View File

@@ -47,7 +47,7 @@ public class tracy : ThirdPartyModule
switch (options.Platform.Target) switch (options.Platform.Target)
{ {
case TargetPlatform.Windows: case TargetPlatform.Windows:
options.PrivateDefinitions.Add("TRACY_DBGHELP_LOCK=DbgHelp"); options.PrivateDefinitions.Add("TRACY_DBGHELP_LOCK=FlaxDbgHelp");
break; break;
case TargetPlatform.Switch: case TargetPlatform.Switch:
options.PrivateDefinitions.Add("TRACY_USE_MALLOC"); options.PrivateDefinitions.Add("TRACY_USE_MALLOC");