diff options
Diffstat (limited to 'runtime/src/main.cpp')
| -rw-r--r-- | runtime/src/main.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 98e377f1c..d386de0cd 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <exception> | 24 | #include <exception> |
| 25 | #include <filesystem> | 25 | #include <filesystem> |
| 26 | #include <map> | 26 | #include <map> |
| 27 | #include <mutex> | ||
| 27 | #include <string> | 28 | #include <string> |
| 28 | #include <system_error> | 29 | #include <system_error> |
| 29 | #include <vector> | 30 | #include <vector> |
| @@ -261,11 +262,16 @@ static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI title_set_unhandled_exception_filter( | |||
| 261 | static LONG WINAPI save_caches_on_fatal_exception(EXCEPTION_POINTERS* info) { | 262 | static LONG WINAPI save_caches_on_fatal_exception(EXCEPTION_POINTERS* info) { |
| 262 | const DWORD code = info && info->ExceptionRecord ? info->ExceptionRecord->ExceptionCode : 0; | 263 | const DWORD code = info && info->ExceptionRecord ? info->ExceptionRecord->ExceptionCode : 0; |
| 263 | if (code != EXCEPTION_STACK_OVERFLOW) { | 264 | if (code != EXCEPTION_STACK_OVERFLOW) { |
| 264 | std::fprintf(stderr, "[rt] unhandled exception 0x%08lx: writing the session pipeline cache before the " | 265 | // Several title threads can fault at once (measured: eight within a second). The first writes; the others |
| 265 | "process ends\n", static_cast<unsigned long>(code)); | 266 | // wait here for it, so none of them reaches the title's filter, which may end the process, mid-write. |
| 266 | rt::d3d12::stop_pipeline_compiles(kExitCompileWaitMs); | 267 | static std::once_flag once; |
| 267 | rt::d3d12::save_pipeline_caches_at_exit(kExitCacheWaitMs); | 268 | std::call_once(once, [code] { |
| 268 | std::fflush(stderr); | 269 | std::fprintf(stderr, "[rt] unhandled exception 0x%08lx: writing the session pipeline cache before the " |
| 270 | "process ends\n", static_cast<unsigned long>(code)); | ||
| 271 | rt::d3d12::stop_pipeline_compiles(kExitCompileWaitMs); | ||
| 272 | rt::d3d12::save_pipeline_caches_at_exit(kExitCacheWaitMs); | ||
| 273 | std::fflush(stderr); | ||
| 274 | }); | ||
| 269 | } | 275 | } |
| 270 | if (auto* title = reinterpret_cast<LPTOP_LEVEL_EXCEPTION_FILTER>( | 276 | if (auto* title = reinterpret_cast<LPTOP_LEVEL_EXCEPTION_FILTER>( |
| 271 | InterlockedCompareExchangePointer(&title_fatal_filter, nullptr, nullptr))) | 277 | InterlockedCompareExchangePointer(&title_fatal_filter, nullptr, nullptr))) |