Skip to content

Commit bb98fb6

Browse files
committed
1.6: Addendum to ea33335 (C++ 17 constraints)
1 parent ea33335 commit bb98fb6

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Client/core/CrashHandler.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <cstdint>
2929
#include <exception>
3030
#include <errno.h>
31-
#include <format>
3231
#include <intrin.h>
3332
#include <mutex>
3433
#include <new>
@@ -170,13 +169,13 @@ static void StoreBasicExceptionInfo(_EXCEPTION_POINTERS* pException) noexcept
170169
return;
171170
}
172171

173-
g_lastExceptionInfo = ENHANCED_EXCEPTION_INFO{
174-
.exceptionCode = pException->ExceptionRecord->ExceptionCode,
175-
.exceptionAddress = pException->ExceptionRecord->ExceptionAddress,
176-
.timestamp = std::chrono::system_clock::now(),
177-
.threadId = GetCurrentThreadId(),
178-
.processId = GetCurrentProcessId()
179-
};
172+
ENHANCED_EXCEPTION_INFO info;
173+
info.exceptionCode = pException->ExceptionRecord->ExceptionCode;
174+
info.exceptionAddress = pException->ExceptionRecord->ExceptionAddress;
175+
info.timestamp = std::chrono::system_clock::now();
176+
info.threadId = GetCurrentThreadId();
177+
info.processId = GetCurrentProcessId();
178+
g_lastExceptionInfo = info;
180179
}
181180
catch (...)
182181
{
@@ -1309,7 +1308,9 @@ static bool SafeSymGetLineFromAddr64(HANDLE hProcess, DWORD64 address, DWORD* pD
13091308

13101309
const DWORD64 address = frame.AddrPC.Offset;
13111310

1312-
auto symbolName = std::format("0x{:X}", address);
1311+
char addressBuffer[32];
1312+
snprintf(addressBuffer, sizeof(addressBuffer), "0x%llX", static_cast<unsigned long long>(address));
1313+
std::string symbolName = addressBuffer;
13131314

13141315
// Protect DbgHelp symbol lookups with SEH - addresses may be invalid/in guard pages
13151316
// Especially important for corrupted stacks (callbacks, overflows, heap corruption)
@@ -1329,11 +1330,15 @@ static bool SafeSymGetLineFromAddr64(HANDLE hProcess, DWORD64 address, DWORD* pD
13291330
{
13301331
if (lineInfo.FileName != nullptr)
13311332
{
1332-
frameInfo += std::format(" ({}:{})", lineInfo.FileName, lineInfo.LineNumber);
1333+
char lineBuffer[512];
1334+
snprintf(lineBuffer, sizeof(lineBuffer), " (%s:%lu)", lineInfo.FileName, lineInfo.LineNumber);
1335+
frameInfo += lineBuffer;
13331336
}
13341337
}
13351338

1336-
frameInfo += std::format(" [0x{:X}]", address);
1339+
char addrSuffixBuffer[32];
1340+
snprintf(addrSuffixBuffer, sizeof(addrSuffixBuffer), " [0x%llX]", static_cast<unsigned long long>(address));
1341+
frameInfo += addrSuffixBuffer;
13371342
pOutTrace->push_back(frameInfo);
13381343
}
13391344

0 commit comments

Comments
 (0)