2022-01-27 05:24:08 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: ExceptionWatcher.NT.cpp
|
|
|
|
Date: 2022-1-26
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#include <Source/RuntimeInternal.hpp>
|
|
|
|
#include "ExceptionWatcher.NT.hpp"
|
|
|
|
#include <ehdata.h>
|
|
|
|
|
|
|
|
#if defined(AURORA_PLATFORM_WIN32)
|
|
|
|
#include "ExceptionWatcher.Win32.hpp"
|
|
|
|
#include "Stack.Win32.hpp"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "Debug.hpp"
|
|
|
|
#include <Source/Telemetry/Telemetry.hpp>
|
2022-11-17 07:46:07 +00:00
|
|
|
#include <Source/Grug/AuGrug.hpp>
|
|
|
|
#include <Source/Exit/AuExit.hpp>
|
2022-11-30 11:11:18 +00:00
|
|
|
#include "ErrorStack.hpp"
|
2022-01-27 05:24:08 +00:00
|
|
|
|
|
|
|
namespace Aurora::Debug
|
|
|
|
{
|
|
|
|
static std::string kStringRawName = typeid(std::string).raw_name();
|
|
|
|
|
|
|
|
static bool IsReadable(const void *address)
|
|
|
|
{
|
|
|
|
MEMORY_BASIC_INFORMATION info;
|
|
|
|
|
|
|
|
if (!VirtualQuery(address, &info, sizeof(info)))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!info.BaseAddress)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (info.Protect & (PAGE_READONLY | PAGE_READWRITE)) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuString ReportSEH(HMODULE handle, void *exception, const void *throwInfo, const AuFunction<AuString()> &resolveFallback, const StackTrace &trace, const AuFunction<void(const AuString &)> &prereport)
|
|
|
|
{
|
|
|
|
AuString message;
|
|
|
|
|
2023-06-24 20:21:00 +00:00
|
|
|
if (throwInfo)
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
2023-06-24 20:21:00 +00:00
|
|
|
if (handle != INVALID_HANDLE_VALUE)
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
2023-06-24 20:21:00 +00:00
|
|
|
try
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
2023-06-24 20:21:00 +00:00
|
|
|
const ThrowInfo *pthrowInfo = reinterpret_cast<const ThrowInfo *>(throwInfo);
|
|
|
|
auto attribs = pthrowInfo->attributes;
|
2022-01-27 05:24:08 +00:00
|
|
|
|
2023-06-24 20:21:00 +00:00
|
|
|
const auto catchableTypeArray = reinterpret_cast<const CatchableTypeArray *>(reinterpret_cast<AuUInt>(handle) + (AuUInt)(pthrowInfo->pCatchableTypeArray));
|
2022-01-27 05:24:08 +00:00
|
|
|
|
2023-06-24 20:21:00 +00:00
|
|
|
AuString suffix;
|
|
|
|
for (int i = 0; i < catchableTypeArray->nCatchableTypes; i++)
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
2023-06-24 20:21:00 +00:00
|
|
|
const auto type = reinterpret_cast<CatchableType *> (reinterpret_cast<AuUInt>(handle) + (AuUInt)(catchableTypeArray->arrayOfCatchableTypes[i]));
|
|
|
|
const auto descriptor = reinterpret_cast<std::type_info *> (reinterpret_cast<AuUInt>(handle) + (AuUInt)(type->pType));
|
|
|
|
|
|
|
|
message += (i == 0 ? "" : AuString(", ")) + descriptor->name(); // __std_type_info_name
|
|
|
|
|
|
|
|
if (_strnicmp(descriptor->raw_name(), ".?AVException@", 15 - 1) == 0)
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
2023-06-24 20:21:00 +00:00
|
|
|
auto exception2 = reinterpret_cast<std::exception *>(exception);
|
|
|
|
auto wptr = exception2->what();
|
|
|
|
if (wptr)
|
|
|
|
{
|
|
|
|
suffix = wptr;
|
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
}
|
2023-06-24 20:21:00 +00:00
|
|
|
else if (_strnicmp(descriptor->raw_name(), ".PEAD", 5) == 0)
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
2023-06-24 20:21:00 +00:00
|
|
|
auto possibleStringPointer = reinterpret_cast<const char **>(exception);
|
|
|
|
if (IsReadable(possibleStringPointer))
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
2023-06-24 20:21:00 +00:00
|
|
|
auto string = *possibleStringPointer;
|
|
|
|
if (IsReadable(string) && (strnlen(string, 4096) < 1024))
|
|
|
|
{
|
|
|
|
suffix = string;
|
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-24 20:21:00 +00:00
|
|
|
else if (_strnicmp(descriptor->raw_name(), kStringRawName.data(), kStringRawName.size()) == 0)
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
2023-06-24 20:21:00 +00:00
|
|
|
auto possibleStdStringPointer = reinterpret_cast<std::string *>(exception);
|
|
|
|
if (IsReadable(possibleStdStringPointer))
|
|
|
|
{
|
|
|
|
suffix = *possibleStdStringPointer;
|
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-24 20:21:00 +00:00
|
|
|
if (suffix.size())
|
|
|
|
{
|
|
|
|
message += AuString("\r\n ") + suffix;
|
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
}
|
2023-06-24 20:21:00 +00:00
|
|
|
catch (...)
|
|
|
|
{
|
2022-01-27 05:24:08 +00:00
|
|
|
|
2023-06-24 20:21:00 +00:00
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-24 20:21:00 +00:00
|
|
|
if (message.find("invalid sto") != AuString::npos)
|
|
|
|
{
|
|
|
|
return message;
|
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (message.empty() && resolveFallback)
|
|
|
|
{
|
|
|
|
message = resolveFallback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prereport)
|
|
|
|
{
|
|
|
|
prereport(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Telemetry::NewBlockboxEntry entry;
|
|
|
|
entry.type = Telemetry::ENewBlackBoxEntry::eStackWarning;
|
|
|
|
entry.stack.fenceId = ReportStackTrace(trace, message);
|
|
|
|
entry.stack.backtrace = trace;
|
|
|
|
Telemetry::Report(entry);
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-11-30 11:11:18 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
auto pStr = AuMakeSharedThrow<AuString>(message);
|
|
|
|
// auto pTrace = AuMakeSharedThrow<StackTrace>(trace);
|
|
|
|
|
|
|
|
if (ShouldPushErrorStackInternal())
|
|
|
|
{
|
|
|
|
auto pMessage = AuMakeSharedThrow<ThreadMessage>();
|
|
|
|
pMessage->optStackTrace = trace;
|
|
|
|
pMessage->pStringMessage = pStr;
|
|
|
|
PushErrorStackInternal(pMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-01-27 05:24:08 +00:00
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HandleFatal(bool fatal, _EXCEPTION_POINTERS *pExceptionInfo)
|
|
|
|
{
|
|
|
|
static bool handlingFatal = false;
|
|
|
|
|
2022-06-01 14:25:32 +00:00
|
|
|
#if defined(AU_ENABLE_NATIVE_MINIDUMP)
|
2022-01-27 05:24:08 +00:00
|
|
|
if (!fatal)
|
|
|
|
{
|
2023-06-28 03:48:11 +00:00
|
|
|
if (gRuntimeConfig.debug.bRaiseDebuggerToAllExceptionsInStageAndDbg &&
|
|
|
|
IsDebuggerPresent())
|
|
|
|
{
|
|
|
|
__debugbreak();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gRuntimeConfig.debug.bSaveAllExceptionsAsMinidumpInBg)
|
|
|
|
{
|
|
|
|
BlackboxReport(pExceptionInfo, false);
|
|
|
|
}
|
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-27 20:25:04 +00:00
|
|
|
SaveMinidump(pExceptionInfo, true);
|
2022-01-27 05:24:08 +00:00
|
|
|
}
|
|
|
|
#else
|
2023-06-28 03:48:11 +00:00
|
|
|
if (fatal)
|
|
|
|
{
|
|
|
|
BlackboxReport(pExceptionInfo, true);
|
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
#endif
|
|
|
|
}
|
2023-06-24 19:43:32 +00:00
|
|
|
|
|
|
|
void PlatformHandleFatalEx2(bool fatal, CONTEXT &ctx, bool bNoExit);
|
2022-01-27 05:24:08 +00:00
|
|
|
|
2023-05-31 07:09:44 +00:00
|
|
|
void PlatformHandleFatal(bool fatal, bool bNoExit)
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
2023-03-31 03:24:19 +00:00
|
|
|
CONTEXT ctx {};
|
|
|
|
ctx.ContextFlags = CONTEXT_ALL;
|
|
|
|
|
2022-01-27 05:24:08 +00:00
|
|
|
if (!GetThreadContext(GetCurrentThread(), &ctx))
|
|
|
|
{
|
|
|
|
Debug::Panic();
|
|
|
|
}
|
|
|
|
|
2023-06-24 19:43:32 +00:00
|
|
|
PlatformHandleFatalEx2(fatal, ctx, bNoExit);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformHandleFatalEx2(bool fatal, CONTEXT & ctx, bool bNoExit)
|
|
|
|
{
|
|
|
|
static bool forceFail { false };
|
|
|
|
_EXCEPTION_POINTERS ptrs;
|
|
|
|
StackTrace ret;
|
|
|
|
EXCEPTION_RECORD ex {};
|
|
|
|
|
2023-05-31 07:09:44 +00:00
|
|
|
if (!bNoExit)
|
2022-01-28 01:16:14 +00:00
|
|
|
{
|
2023-05-31 07:09:44 +00:00
|
|
|
if (!AuExchange(forceFail, true))
|
|
|
|
{
|
|
|
|
Exit::PostLevel(AuThreads::GetThread(), Exit::ETriggerLevel::eFatalException);
|
|
|
|
}
|
2022-01-28 01:16:14 +00:00
|
|
|
}
|
|
|
|
|
2023-03-31 03:24:19 +00:00
|
|
|
ex.ExceptionCode = 0x1337;
|
2023-06-24 19:43:32 +00:00
|
|
|
|
2023-03-31 03:24:19 +00:00
|
|
|
ptrs.ExceptionRecord = &ex;
|
2022-01-27 05:24:08 +00:00
|
|
|
ptrs.ContextRecord = &ctx;
|
2023-03-31 03:24:19 +00:00
|
|
|
|
2022-01-27 05:24:08 +00:00
|
|
|
HandleFatal(fatal, &ptrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitNT()
|
|
|
|
{
|
2022-09-12 22:38:44 +00:00
|
|
|
if (!gRuntimeConfig.debug.bEnableInjectedExceptionHandler)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[*/+/-] MEGA COMMIT. ~2 weeks compressed.
The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api.
[+] AuMakeSharedArray
[+] Technet ArgvQuote
[+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.)
[+] auEndianness -> Endian swap utils
[+] AuGet<N>(...)
[*] AUE_DEFINE conversion for
ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump
[+] ConsoleMessage ByteBuffer serialization
[+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks
[*] Split logger from console subsystem
[+] StartupParameters -> A part of a clean up effort under Process
[*] Refactor SysErrors header + get caller hack
[+] Atomic APIs
[+] popcnt
[+] Ring Buffer sink
[+] Added more standard errors
Catch,
Submission,
LockError,
NoAccess,
ResourceMissing,
ResourceLocked,
MalformedData,
InSandboxContext,
ParseError
[+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace
[+] IExitSubscriber, ETriggerLevel
[*] Write bias the high performance RWLockImpl read-lock operation operation
[+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem)
[*] Updated API style
Digests
[+] CpuId::CpuBitCount
[+] GetUserProgramsFolder
[+] GetPackagePath
[*] Split IStreamReader with an inl file
[*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer
[+] ICharacterProvider
[+] ICharacterProviderEx
[+] IBufferedCharacterConsumer
[+] ProviderFromSharedString
[+] ProviderFromString
[+] BufferConsumerFromProvider
[*] Parse Subsystem uses character io bufferer
[*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore]
[+] ByteBuffer::ResetReadPointer
[*] Bug fix bytebuffer base not reset on free and some scaling issues
[+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section
[*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing
[+] Added 64 *byte* fast RNG seeds
[+] File Advisorys/File Lock Awareness
[+] Added extended IAuroraThread from OS identifier caches for debug purposes
[*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions.
[*] Broke AuroraUtils/Typedefs out into a separate library
[*] Update build script
[+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media
[*] Improved public API documentation
[*] Bug fix `SetConsoleCtrlHandler`
[+] Locale TimeDateToFileNameISO8601
[+] Console config stdOutShortTime
[*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl)
[*] Bug fixes in decoders
[*] Major bug fix, AuMax
[+] RateLimiter
[+] Binary file sink
[+] Log directory sink
[*] Data header usability (more operators)
[+] AuRemoveRange
[+] AuRemove
[+] AuTryRemove
[+] AuTryRemoveRange
[+] auCastUtils
[+] Finish NewLSWin32Source
[+] AuTryFindByTupleN, AuTryRemoveByTupleN
[+] Separated AuRead/Write types, now in auTypeUtils
[+] Added GetPosition/SetPosition to FileWriter
[*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp
[*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position)
[*] Hack back in the sched deinit
[+] File AIO loop source interop
[+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw
[+] Stub code for networking
[+] Compression BaseStream/IngestableStreamBase
[*] Major: read/write locks now support write-entrant read routines.
[*] Compression subsystem now uses the MemoryView concept
[*] Rewrite the base stream compressions, made them less broken
[*] Update hashing api
[*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing
[+] Added new AuByteBuffer apis
Trim, Pad, WriteFrom, WriteString, [TODO: ReadString]
[+] Added ByteBufferPushReadState
[+] Added ByteBufferPushWriteState
[*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16.
[*] ELogLevel is now an Aurora enum
[+] Raised arbitrary limit in header to 255, the max filter buffer
[+] Explicit GZip support
[+] Explicit Zip support
[+] Added [some] compressors
et al
2022-02-17 00:11:40 +00:00
|
|
|
// i dont think we need a slow grug path for windows
|
|
|
|
// "runs in the same thread context" (- msdn) =/= we will run out of the old threads stack
|
2022-09-12 22:38:44 +00:00
|
|
|
// cant be any worse than unix &~ ONSTACK traps (ironically on-stack being shorthand for onstack on an alt heap)
|
|
|
|
|
2022-01-27 05:24:08 +00:00
|
|
|
SetUnhandledExceptionFilter([](_EXCEPTION_POINTERS *pExceptionInfo) -> LONG
|
|
|
|
{
|
[*/+/-] MEGA COMMIT. ~2 weeks compressed.
The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api.
[+] AuMakeSharedArray
[+] Technet ArgvQuote
[+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.)
[+] auEndianness -> Endian swap utils
[+] AuGet<N>(...)
[*] AUE_DEFINE conversion for
ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump
[+] ConsoleMessage ByteBuffer serialization
[+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks
[*] Split logger from console subsystem
[+] StartupParameters -> A part of a clean up effort under Process
[*] Refactor SysErrors header + get caller hack
[+] Atomic APIs
[+] popcnt
[+] Ring Buffer sink
[+] Added more standard errors
Catch,
Submission,
LockError,
NoAccess,
ResourceMissing,
ResourceLocked,
MalformedData,
InSandboxContext,
ParseError
[+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace
[+] IExitSubscriber, ETriggerLevel
[*] Write bias the high performance RWLockImpl read-lock operation operation
[+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem)
[*] Updated API style
Digests
[+] CpuId::CpuBitCount
[+] GetUserProgramsFolder
[+] GetPackagePath
[*] Split IStreamReader with an inl file
[*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer
[+] ICharacterProvider
[+] ICharacterProviderEx
[+] IBufferedCharacterConsumer
[+] ProviderFromSharedString
[+] ProviderFromString
[+] BufferConsumerFromProvider
[*] Parse Subsystem uses character io bufferer
[*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore]
[+] ByteBuffer::ResetReadPointer
[*] Bug fix bytebuffer base not reset on free and some scaling issues
[+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section
[*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing
[+] Added 64 *byte* fast RNG seeds
[+] File Advisorys/File Lock Awareness
[+] Added extended IAuroraThread from OS identifier caches for debug purposes
[*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions.
[*] Broke AuroraUtils/Typedefs out into a separate library
[*] Update build script
[+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media
[*] Improved public API documentation
[*] Bug fix `SetConsoleCtrlHandler`
[+] Locale TimeDateToFileNameISO8601
[+] Console config stdOutShortTime
[*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl)
[*] Bug fixes in decoders
[*] Major bug fix, AuMax
[+] RateLimiter
[+] Binary file sink
[+] Log directory sink
[*] Data header usability (more operators)
[+] AuRemoveRange
[+] AuRemove
[+] AuTryRemove
[+] AuTryRemoveRange
[+] auCastUtils
[+] Finish NewLSWin32Source
[+] AuTryFindByTupleN, AuTryRemoveByTupleN
[+] Separated AuRead/Write types, now in auTypeUtils
[+] Added GetPosition/SetPosition to FileWriter
[*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp
[*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position)
[*] Hack back in the sched deinit
[+] File AIO loop source interop
[+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw
[+] Stub code for networking
[+] Compression BaseStream/IngestableStreamBase
[*] Major: read/write locks now support write-entrant read routines.
[*] Compression subsystem now uses the MemoryView concept
[*] Rewrite the base stream compressions, made them less broken
[*] Update hashing api
[*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing
[+] Added new AuByteBuffer apis
Trim, Pad, WriteFrom, WriteString, [TODO: ReadString]
[+] Added ByteBufferPushReadState
[+] Added ByteBufferPushWriteState
[*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16.
[*] ELogLevel is now an Aurora enum
[+] Raised arbitrary limit in header to 255, the max filter buffer
[+] Explicit GZip support
[+] Explicit Zip support
[+] Added [some] compressors
et al
2022-02-17 00:11:40 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
AuLogWarn("Handling fatal NT err exception...");
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
HandleFatal(true, pExceptionInfo);
|
|
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-07 01:29:09 +00:00
|
|
|
#include "MemoryCrunch.hpp"
|
|
|
|
|
2022-01-27 05:24:08 +00:00
|
|
|
static thread_local AuUInt tlsThrowCounter;
|
|
|
|
|
|
|
|
extern "C" AUKN_SYM void __stdcall _ReportMSVCSEH(void *exception, const void *throwInfo, void *caller)
|
|
|
|
{
|
2023-08-10 02:34:44 +00:00
|
|
|
AU_DEBUG_MEMCRUNCH;
|
2022-12-07 01:29:09 +00:00
|
|
|
|
2022-01-27 20:25:04 +00:00
|
|
|
if (!throwInfo)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!exception)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
|
|
|
|
HMODULE handle = 0;
|
|
|
|
|
|
|
|
if (_EH_RELATIVE_TYPEINFO)
|
|
|
|
{
|
|
|
|
if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast<LPCSTR>(caller), reinterpret_cast<HMODULE *>(&handle)))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (handle == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we will probably overflow for a bit if an inner try catch borks up somewhere
|
2022-12-07 01:29:09 +00:00
|
|
|
if ((tlsThrowCounter++) == 7) // TODO: this might be stupid. we should configure for panic on second
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
|
|
|
tlsThrowCounter--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
auto trace = AuDebug::GetStackTrace();
|
2022-06-16 00:27:00 +00:00
|
|
|
|
2022-09-12 22:38:44 +00:00
|
|
|
if (gRuntimeConfig.debug.bPrintExceptionStackTracesOut)
|
2022-01-27 05:24:08 +00:00
|
|
|
{
|
2022-06-16 00:27:00 +00:00
|
|
|
AuDebug::ReportSEH(handle, exception, throwInfo, {}, trace,
|
|
|
|
[&](const AuString &str)
|
|
|
|
{
|
|
|
|
AuLogWarn("Local MSVC Exception: 0x{:x}, {}", exception, str.c_str());
|
|
|
|
AuLogWarn("{}", StringifyStackTrace(trace));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AuDebug::ReportSEH(handle, exception, throwInfo, {}, trace,
|
|
|
|
[&](const AuString &str) {});
|
|
|
|
}
|
2022-01-27 05:24:08 +00:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
[*/+/-] MEGA COMMIT. ~2 weeks compressed.
The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api.
[+] AuMakeSharedArray
[+] Technet ArgvQuote
[+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.)
[+] auEndianness -> Endian swap utils
[+] AuGet<N>(...)
[*] AUE_DEFINE conversion for
ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump
[+] ConsoleMessage ByteBuffer serialization
[+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks
[*] Split logger from console subsystem
[+] StartupParameters -> A part of a clean up effort under Process
[*] Refactor SysErrors header + get caller hack
[+] Atomic APIs
[+] popcnt
[+] Ring Buffer sink
[+] Added more standard errors
Catch,
Submission,
LockError,
NoAccess,
ResourceMissing,
ResourceLocked,
MalformedData,
InSandboxContext,
ParseError
[+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace
[+] IExitSubscriber, ETriggerLevel
[*] Write bias the high performance RWLockImpl read-lock operation operation
[+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem)
[*] Updated API style
Digests
[+] CpuId::CpuBitCount
[+] GetUserProgramsFolder
[+] GetPackagePath
[*] Split IStreamReader with an inl file
[*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer
[+] ICharacterProvider
[+] ICharacterProviderEx
[+] IBufferedCharacterConsumer
[+] ProviderFromSharedString
[+] ProviderFromString
[+] BufferConsumerFromProvider
[*] Parse Subsystem uses character io bufferer
[*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore]
[+] ByteBuffer::ResetReadPointer
[*] Bug fix bytebuffer base not reset on free and some scaling issues
[+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section
[*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing
[+] Added 64 *byte* fast RNG seeds
[+] File Advisorys/File Lock Awareness
[+] Added extended IAuroraThread from OS identifier caches for debug purposes
[*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions.
[*] Broke AuroraUtils/Typedefs out into a separate library
[*] Update build script
[+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media
[*] Improved public API documentation
[*] Bug fix `SetConsoleCtrlHandler`
[+] Locale TimeDateToFileNameISO8601
[+] Console config stdOutShortTime
[*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl)
[*] Bug fixes in decoders
[*] Major bug fix, AuMax
[+] RateLimiter
[+] Binary file sink
[+] Log directory sink
[*] Data header usability (more operators)
[+] AuRemoveRange
[+] AuRemove
[+] AuTryRemove
[+] AuTryRemoveRange
[+] auCastUtils
[+] Finish NewLSWin32Source
[+] AuTryFindByTupleN, AuTryRemoveByTupleN
[+] Separated AuRead/Write types, now in auTypeUtils
[+] Added GetPosition/SetPosition to FileWriter
[*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp
[*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position)
[*] Hack back in the sched deinit
[+] File AIO loop source interop
[+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw
[+] Stub code for networking
[+] Compression BaseStream/IngestableStreamBase
[*] Major: read/write locks now support write-entrant read routines.
[*] Compression subsystem now uses the MemoryView concept
[*] Rewrite the base stream compressions, made them less broken
[*] Update hashing api
[*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing
[+] Added new AuByteBuffer apis
Trim, Pad, WriteFrom, WriteString, [TODO: ReadString]
[+] Added ByteBufferPushReadState
[+] Added ByteBufferPushWriteState
[*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16.
[*] ELogLevel is now an Aurora enum
[+] Raised arbitrary limit in header to 255, the max filter buffer
[+] Explicit GZip support
[+] Explicit Zip support
[+] Added [some] compressors
et al
2022-02-17 00:11:40 +00:00
|
|
|
Aurora::Exit::PostLevel(AuThreads::GetThread(), Aurora::Exit::ETriggerLevel::eProblematicEvent);
|
2022-01-27 05:24:08 +00:00
|
|
|
tlsThrowCounter--;
|
|
|
|
}
|