mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 12:08:36 +00:00
main: the title's hang watchdog stays armed unless LEONIDA_TITLE_WATCHDOG=0
The retail title runs its own hang watchdog: when the game's main loop has not reported for 30 seconds, it ends itself. #984 kept that watchdog from firing by default, because under the runtime the game thread can wait longer than that, for example while the driver compiles pipelines on the first boot after a driver update. By the maintainer's decision the watchdog now stays armed by default, as on the console, so a real hang still ends the run. LEONIDA_TITLE_WATCHDOG=0 turns on the runtime thread that keeps it from firing; as before, it only acts in the build the watchdog was measured in. The README's environment table and the log line say the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -334,7 +334,7 @@ ones marked *diagnostic* only add log lines or exist to compare a run with and w
|
||||
| `LEONIDA_SHADOW_FULL_WALK` | unset | *Diagnostic.* `1` queries every page of the title-memory shadows at every refresh, as before unchanged generations were skipped. |
|
||||
| `LEONIDA_STRICT_REPLAY` | unset | *Diagnostic.* `1` makes a draw or dispatch with an unresolvable resource fail its command list (`src/vulkan_replay.h`); by default it is dropped and logged. |
|
||||
| `LEONIDA_VOLUME_MIPS` | on | The XG layout of a 3D texture with mips or a block format is computed (`shims/xg_xs_layout.h`). `0` refuses it. |
|
||||
| `LEONIDA_TITLE_WATCHDOG` | unset | `1` leaves the title's own hang watchdog armed. By default `gta6rt --run` keeps it from firing while the game thread waits for the driver (`src/main.cpp`), and only in the build the watchdog was measured in. |
|
||||
| `LEONIDA_TITLE_WATCHDOG` | unset (armed) | The title's own hang watchdog stays armed by default, as on the console: if the game's main loop does not report for 30 seconds, the title ends itself. `0` makes `gta6rt --run` keep it from firing while the game thread waits for the driver, for example on the first boot after a driver update (`src/main.cpp`), and only in the build the watchdog was measured in. |
|
||||
| `LEONIDA_PEEK_SECONDS` | `10` | *Diagnostic.* The period of the `LEONIDA_PEEK` thread (`src/main.cpp`), which prints 8-byte values of the title's image. |
|
||||
| `LEONIDA_INPUT_LOG` | on | The GameInput shim logs every press in `LEONIDA_INPUT_SCRIPT`'s form (`name@seconds`), so a session played by hand can be replayed. `0` turns the lines off. |
|
||||
| `LEONIDA_LOG_ALLOCINFO` | unset | *Diagnostic.* `1` logs every device slot 25 call (`GetResourceAllocationInfo`) with its thread, description and sizes (`shims/d3d12_xs_device.cpp`). |
|
||||
|
||||
@ -36,15 +36,16 @@ namespace {
|
||||
// has not set its "kick" byte (RVA 0x71b6331) for 30 one-second ticks, it calls a crash callback and then writes to
|
||||
// address 0 (`movl $0, 0` at RVA 0x2215c35). Under the runtime the game thread can legitimately stall for longer than
|
||||
// that, e.g. while the driver compiles pipelines against a cold cache (first boot after a driver update), and the
|
||||
// title then kills itself. Unless LEONIDA_TITLE_WATCHDOG=1, and only when that exact trap instruction sits where it
|
||||
// does in this build, a runtime thread sets the kick byte twice a second so the title's watchdog never fires.
|
||||
// title then kills itself. By default the watchdog stays armed, as on the console. With LEONIDA_TITLE_WATCHDOG=0, and
|
||||
// only when that exact trap instruction sits where it does in this build, a runtime thread sets the kick byte twice a
|
||||
// second so the title's watchdog never fires.
|
||||
constexpr std::uint32_t kWatchdogTrapRva = 0x2215c35;
|
||||
constexpr std::uint32_t kWatchdogKickRva = 0x71b6331;
|
||||
constexpr unsigned char kWatchdogTrap[] = {0xC7, 0x04, 0x25, 0, 0, 0, 0, 0, 0, 0, 0}; // movl $0, 0x0
|
||||
|
||||
void keep_title_watchdog_kicked(std::uint8_t* base) {
|
||||
char keep[4]{};
|
||||
if (GetEnvironmentVariableA("LEONIDA_TITLE_WATCHDOG", keep, sizeof(keep)) == 1 && keep[0] == '1') return;
|
||||
char value[4]{};
|
||||
if (GetEnvironmentVariableA("LEONIDA_TITLE_WATCHDOG", value, sizeof(value)) != 1 || value[0] != '0') return;
|
||||
MEMORY_BASIC_INFORMATION trap{}, kick{};
|
||||
if (!VirtualQuery(base + kWatchdogTrapRva, &trap, sizeof(trap)) || trap.State != MEM_COMMIT ||
|
||||
std::memcmp(base + kWatchdogTrapRva, kWatchdogTrap, sizeof(kWatchdogTrap)) != 0)
|
||||
@ -66,7 +67,7 @@ void keep_title_watchdog_kicked(std::uint8_t* base) {
|
||||
const_cast<std::uint8_t*>(byte), 0, nullptr);
|
||||
if (thread) {
|
||||
CloseHandle(thread);
|
||||
std::fprintf(stderr, "[rt] loader: keeping the title's hang watchdog kicked (LEONIDA_TITLE_WATCHDOG=1 keeps it armed)\n");
|
||||
std::fprintf(stderr, "[rt] loader: keeping the title's hang watchdog kicked (LEONIDA_TITLE_WATCHDOG=0; unset or 1 keeps it armed)\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user