[*] Force NT exception handles to create the directory tree if not present.

[*] Fix panic on mayday
This commit is contained in:
Reece Wilson 2022-01-27 08:14:48 +00:00
parent 5bc1985eca
commit b1c4e26f91
3 changed files with 18 additions and 7 deletions

View File

@ -152,14 +152,14 @@ namespace Aurora::Debug
if (!fatal)
{
if (IsDebuggerPresent()) __debugbreak();
else BlackboxReport(pExceptionInfo);
else BlackboxReport(pExceptionInfo, false);
}
else
{
SaveMinidump(pExceptionInfo);
}
#else
BlackboxReport(pExceptionInfo);
BlackboxReport(pExceptionInfo, true);
#endif
}

View File

@ -246,11 +246,13 @@ namespace Aurora::Debug
MiniDumpWithThreadInfo;
std::wstring path;
AuString utf8Path;
while (path.empty())
{
try
{
path = Locale::ConvertFromUTF8(AuIOFS::NormalizePathRet("./Logs/Crashes/" + GetDumpName()));
utf8Path = AuIOFS::NormalizePathRet("./Logs/Crashes/" + GetDumpName());
path = Locale::ConvertFromUTF8(utf8Path);
}
catch (...)
{
@ -258,6 +260,8 @@ namespace Aurora::Debug
}
}
AuIOFS::CreateDirectories(utf8Path, true);
auto hFile = CreateFileW(path.c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE)
{
@ -290,11 +294,12 @@ namespace Aurora::Debug
}
#endif
void BlackboxReport(_EXCEPTION_POINTERS *ExceptionInfo)
void BlackboxReport(_EXCEPTION_POINTERS *ExceptionInfo, bool fatal)
{
AuString path;
HANDLE hFile;
std::wstring wpath;
AuString utf8Path;
MINIDUMP_EXCEPTION_INFORMATION info;
auto ok = AuIOFS::GetProfileDomain(path);
@ -319,7 +324,8 @@ namespace Aurora::Debug
{
try
{
wpath = Locale::ConvertFromUTF8(path + "Crashes/" + GetDumpName());
utf8Path = path + "Crashes/" + GetDumpName();
wpath = Locale::ConvertFromUTF8(utf8Path);
}
catch (...)
{
@ -327,6 +333,8 @@ namespace Aurora::Debug
}
}
AuIOFS::CreateDirectories(utf8Path, true);
hFile = CreateFileW(wpath.c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile != INVALID_HANDLE_VALUE)
{
@ -350,8 +358,11 @@ namespace Aurora::Debug
report.resource.type = Telemetry::ENewBlackBoxResourceType::eLocal;
Telemetry::ReportDyingBreath(report);
if (fatal)
{
__fastfail('fokd');
}
}
void InitWin32()
{

View File

@ -14,5 +14,5 @@ namespace Aurora::Debug
#if defined(DEBUG) || defined(INTERNAL)
void SaveMinidump(_EXCEPTION_POINTERS *ExceptionInfo);
#endif
void BlackboxReport(_EXCEPTION_POINTERS *ExceptionInfo);
void BlackboxReport(_EXCEPTION_POINTERS *ExceptionInfo, bool isFatal);
}