diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 20:37:26 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 20:37:26 -0500 |
| commit | 38bd89d44e6a790010de5ad22a6b891e7869fdd8 (patch) | |
| tree | bd525ee65267496f1b201fa3d5c138847e7f1c1b /runtime/src/main.cpp | |
| parent | 545e8d51f148ad2c2b26c16b9e1630c634cf5270 (diff) | |
| parent | 71a783e56fb6eb591849b5c9fb6618ed3af3f595 (diff) | |
Merge the #984 result as of 71a783e56 into the #939 merge
Fourteen commits the #984 merge gained after 8a242efeb: its own failing tests (xmem_test under Wine, check_tls_index0, vk_bindless_grow, xs_present_lazy_test), the console-heap probe and the poke experiment behind their switches, Python tool fixes, and the title watchdog default. No conflicts.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/main.cpp')
| -rw-r--r-- | runtime/src/main.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index b57bbca29..a870cb814 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp | |||
| @@ -36,15 +36,16 @@ namespace { | |||
| 36 | // has not set its "kick" byte (RVA 0x71b6331) for 30 one-second ticks, it calls a crash callback and then writes to | 36 | // has not set its "kick" byte (RVA 0x71b6331) for 30 one-second ticks, it calls a crash callback and then writes to |
| 37 | // address 0 (`movl $0, 0` at RVA 0x2215c35). Under the runtime the game thread can legitimately stall for longer than | 37 | // address 0 (`movl $0, 0` at RVA 0x2215c35). Under the runtime the game thread can legitimately stall for longer than |
| 38 | // that, e.g. while the driver compiles pipelines against a cold cache (first boot after a driver update), and the | 38 | // that, e.g. while the driver compiles pipelines against a cold cache (first boot after a driver update), and the |
| 39 | // title then kills itself. Unless LEONIDA_TITLE_WATCHDOG=1, and only when that exact trap instruction sits where it | 39 | // title then kills itself. By default the watchdog stays armed, as on the console. With LEONIDA_TITLE_WATCHDOG=0, and |
| 40 | // does in this build, a runtime thread sets the kick byte twice a second so the title's watchdog never fires. | 40 | // only when that exact trap instruction sits where it does in this build, a runtime thread sets the kick byte twice a |
| 41 | // second so the title's watchdog never fires. | ||
| 41 | constexpr std::uint32_t kWatchdogTrapRva = 0x2215c35; | 42 | constexpr std::uint32_t kWatchdogTrapRva = 0x2215c35; |
| 42 | constexpr std::uint32_t kWatchdogKickRva = 0x71b6331; | 43 | constexpr std::uint32_t kWatchdogKickRva = 0x71b6331; |
| 43 | constexpr unsigned char kWatchdogTrap[] = {0xC7, 0x04, 0x25, 0, 0, 0, 0, 0, 0, 0, 0}; // movl $0, 0x0 | 44 | constexpr unsigned char kWatchdogTrap[] = {0xC7, 0x04, 0x25, 0, 0, 0, 0, 0, 0, 0, 0}; // movl $0, 0x0 |
| 44 | 45 | ||
| 45 | void keep_title_watchdog_kicked(std::uint8_t* base) { | 46 | void keep_title_watchdog_kicked(std::uint8_t* base) { |
| 46 | char keep[4]{}; | 47 | char value[4]{}; |
| 47 | if (GetEnvironmentVariableA("LEONIDA_TITLE_WATCHDOG", keep, sizeof(keep)) == 1 && keep[0] == '1') return; | 48 | if (GetEnvironmentVariableA("LEONIDA_TITLE_WATCHDOG", value, sizeof(value)) != 1 || value[0] != '0') return; |
| 48 | MEMORY_BASIC_INFORMATION trap{}, kick{}; | 49 | MEMORY_BASIC_INFORMATION trap{}, kick{}; |
| 49 | if (!VirtualQuery(base + kWatchdogTrapRva, &trap, sizeof(trap)) || trap.State != MEM_COMMIT || | 50 | if (!VirtualQuery(base + kWatchdogTrapRva, &trap, sizeof(trap)) || trap.State != MEM_COMMIT || |
| 50 | std::memcmp(base + kWatchdogTrapRva, kWatchdogTrap, sizeof(kWatchdogTrap)) != 0) | 51 | std::memcmp(base + kWatchdogTrapRva, kWatchdogTrap, sizeof(kWatchdogTrap)) != 0) |
| @@ -66,7 +67,7 @@ void keep_title_watchdog_kicked(std::uint8_t* base) { | |||
| 66 | const_cast<std::uint8_t*>(byte), 0, nullptr); | 67 | const_cast<std::uint8_t*>(byte), 0, nullptr); |
| 67 | if (thread) { | 68 | if (thread) { |
| 68 | CloseHandle(thread); | 69 | CloseHandle(thread); |
| 69 | std::fprintf(stderr, "[rt] loader: keeping the title's hang watchdog kicked (LEONIDA_TITLE_WATCHDOG=1 keeps it armed)\n"); | 70 | std::fprintf(stderr, "[rt] loader: keeping the title's hang watchdog kicked (LEONIDA_TITLE_WATCHDOG=0; unset or 1 keeps it armed)\n"); |
| 70 | } | 71 | } |
| 71 | } | 72 | } |
| 72 | 73 | ||