From b77c631b8b3acebc1b036f84417368fd21f03c70 Mon Sep 17 00:00:00 2001 From: BlankenshipG Date: Mon, 12 Oct 2026 00:33:21 -0400 Subject: [PATCH] fix(engine): catch native faults in Client::UseTime instead of crashing See Changelog/2026-10-11-gametick-chatclient-guard.md. --- .../2026-10-11-gametick-chatclient-guard.md | 46 ++++++++++ native/SehTrampoline/Build-SehTrampoline.ps1 | 4 + native/SehTrampoline/SehTrampoline.c | 91 ++++++++++++++++++- scripts/Publish-EngineCoreClr.ps1 | 11 ++- .../Compatibility/GameTickHooks.cs | 64 ++++++++++++- .../Compatibility/SehTrampoline.cs | 51 +++++++++++ 6 files changed, 260 insertions(+), 7 deletions(-) create mode 100644 Changelog/2026-10-11-gametick-chatclient-guard.md diff --git a/Changelog/2026-10-11-gametick-chatclient-guard.md b/Changelog/2026-10-11-gametick-chatclient-guard.md new file mode 100644 index 0000000..39a980b --- /dev/null +++ b/Changelog/2026-10-11-gametick-chatclient-guard.md @@ -0,0 +1,46 @@ +# Game-tick crash guard (chatclient.dll null read) + +RynthCore.SehTrampoline.dll native version 4 (previous: 3). + +## The crash + +On 2026-10-11 two idle clients died in the same second. Both CoreCLR dumps show the same fault on +AC's main thread: + +- AC's `Client::UseTime` called into `chatclient.dll` (Turbine's chat client in the AC folder). + Three calls in, a `rep movsd` copy of about 2 MB read from address 0 + (`chatclient.dll+0x1050`, read of 0x00000000). +- Both clients at once, both idle: most likely a bad or oversized message from the chat server. +- The fault unwound into the engine's managed `UseTime` detour. CoreCLR treats a native access + violation there as an unhandled exception and ends the process, so AC's own handlers never ran. + Windows reported the follow-on fault in `coreclr.dll+0x2c27ae`, which is the runtime's fail-fast + path, not the cause. +- `native-crash.log` had no record: a null read is held back until the process exits normally, + and the fail-fast skipped that. + +## The fix + +- `native/SehTrampoline/SehTrampoline.c`: new export `SEH_GameTickThiscall` calls + `int __thiscall fn(this)` under `__try`. On an access violation it returns 0 with the faulting + address (module-relative), the data address and the module name, and writes a full record + (registers and stack sweep) to `native-crash.log`, at most 16 per process. +- `Compatibility/GameTickHooks.cs`: AC's original `UseTime` goes through that wrapper when the + loaded trampoline is version 4 or later. A caught fault drops that one tick, logs an `[ERR]` + line, and returns 1 so AC's game loop keeps running (0 would make AC shut down). After 5 faults + within 30 seconds the guard turns itself off for the session, so a client whose state is + really broken still ends instead of spinning. +- `Compatibility/SehTrampoline.cs`: the P/Invoke, and `NativeVersion` (cached). A running client + keeps the trampoline DLL it started with, so a hot-reloaded engine meeting a v3 DLL logs + "native AV guard OFF" and calls `UseTime` directly, as before. +- `native/SehTrampoline/Build-SehTrampoline.ps1`: `-NoDeploy` builds into `bin\` without + copying to the runtime folder. +- `scripts/Publish-EngineCoreClr.ps1`: a trampoline DLL held by a running client is now moved + aside (`.old-