diff options
| author | kurrutako <kurrutako@users.noreply.github.com> | 2026-11-25 17:06:49 +0100 |
|---|---|---|
| committer | kurrutako <kurrutako@users.noreply.github.com> | 2026-11-25 17:06:49 +0100 |
| commit | 98c457ec4f4bb6da6cdc685badd8019f0635cf4e (patch) | |
| tree | 3313a6431a2b8009f8a361c8aa351bb2e919b272 /runtime/src | |
| parent | a26b12760e6bef631949076261e21dba53f141db (diff) | |
gta6rt: threads that fault together wait for the first one's cache write (RT-SESSION-CACHE-AT-EXIT)
A boot ended with eight title threads faulting within a second. Each
entered the filter; the ones after the first returned at once and went on
to the title's filter, which can end the process during the write. The
write now runs under std::call_once, so they wait for it.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src')
| -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))) |