diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-07 19:05:15 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-07 20:16:27 -0500 |
| commit | 08c952e53a4efcd5b50c0ec947bf216101c027ef (patch) | |
| tree | 30d077e801483d1e9e3cb3ee27a308d255cefe05 /src/main.cpp | |
| parent | b4f6275c3ef888551e14e5d64739e1c32978b8e8 (diff) | |
stopped using core dump stuff from usvfs, mo has its own
set exception handler at the start, it can handle not having qt or data paths
hopefully fixed infinite crash dumps
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp index a2e16cc0..ad074501 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,8 +3,9 @@ #include "moapplication.h" #include "organizercore.h" #include "commandline.h" +#include "env.h" +#include "thread_utils.h" #include "shared/util.h" -#include <usvfs.h> #include <log.h> using namespace MOBase; @@ -17,6 +18,7 @@ int forwardToPrimary(SingleInstance& instance, const cl::CommandLine& cl); int main(int argc, char *argv[]) { MOShared::SetThisThreadName("main"); + setExceptionHandlers(); cl::CommandLine cl; if (auto r=cl.run(GetCommandLineW())) { @@ -53,20 +55,20 @@ int forwardToPrimary(SingleInstance& instance, const cl::CommandLine& cl) LONG WINAPI onUnhandledException(_EXCEPTION_POINTERS* ptrs) { - const std::wstring& dumpPath = OrganizerCore::crashDumpsPath(); + const auto path = OrganizerCore::getGlobalCoreDumpPath(); + const auto type = OrganizerCore::getGlobalCoreDumpType(); - const int r = CreateMiniDump( - ptrs, OrganizerCore::getGlobalCrashDumpsType(), dumpPath.c_str()); + const auto r = env::coredump(path.empty() ? nullptr : path.c_str(), type); - if (r == 0) { - log::error("ModOrganizer has crashed, crash dump created."); + if (r) { + log::error("ModOrganizer has crashed, core dump created."); } else { - log::error( - "ModOrganizer has crashed, CreateMiniDump failed ({}, error {}).", - r, GetLastError()); + log::error("ModOrganizer has crashed, core dump failed"); } - if (g_prevExceptionFilter && ptrs) + // g_prevExceptionFilter somehow sometimes point to this function, making this + // recurse and create hundreds of core dump, not sure why + if (g_prevExceptionFilter && ptrs && g_prevExceptionFilter != onUnhandledException) return g_prevExceptionFilter(ptrs); else return EXCEPTION_CONTINUE_SEARCH; @@ -95,6 +97,11 @@ void onTerminate() noexcept void setExceptionHandlers() { + if (g_prevExceptionFilter) { + // already called + return; + } + g_prevExceptionFilter = SetUnhandledExceptionFilter(onUnhandledException); g_prevTerminateHandler = std::set_terminate(onTerminate); } |
