Engine robustness re-review follow-ups: crash-log flush ring, cast refusal, dump hold cap

- The native crash logger keeps the last 16 first-chance records in a static ring
  (pushed in the VEH: no I/O, no allocation, no loader call). A flush writes the ones
  not yet written, oldest first, each record once. Flushed from the last-chance filter
  and, through the new export RC_FlushCrashLog, from the engine's ExitProcess /
  TerminateProcess / RtlExitUserProcess / NtTerminateProcess detours on a crash code
  (raw unmanaged function pointer, resolved and primed at install). Recovers the fatal
  repeat of an address seen before, which the dedupe skips and which never reaches the
  last-chance filter when a handler terminates the process.
- EnqueueCast refuses during a world transition (CastSlot, pure) and counts the
  refusal in TransitionRejectedCount. The cast slot now owns the stop-wait note the
  cast drain keeps per cast (CastSlot.StopWaitNoted, reset by each queued cast before
  the publishing Volatile.Write of Pending), and DrainCasts reads the queue time once.
- The launcher's dump hold is capped at 15 min per client (DumpInProgressRule.Decide);
  past it the kill checks resume.
- CrashExitRule: ExitProcess(-1) (0xFFFFFFFF) is no longer a crash exit; the rest of
  the 0xC0000000-and-up range is unchanged, so CLR/C++ unhandled-exception exits
  (0xE0434352, 0xE06D7363) still skip managed work.
- The heartbeat line carries qrej=<TransitionRejectedCount>.

Tests: EngineRobustnessTests (adds CastSlot stop-wait and ActionRing.TryPeekAt checks),
CrashLogFilterTests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-10-10 21:53:42 -07:00
commit 636f5d307a
14 changed files with 585 additions and 60 deletions

View file

@ -13,6 +13,9 @@
// - the client's acclient_oom_<pid>_*.dmp file is still being written (modified within
// FileQuietMs).
// The launcher's restart after the dump, for the OOM box that follows, is unchanged.
// A hold never lasts more than MaxHold per client (Decide, from the launcher's first hold
// of that pid): a log kept fresh by some other writer while a marker stays open must not
// shield a dead client forever. Past the cap the kills resume.
//
// Pure. Compiled into tools\EngineRobustnessTests.
// ============================================================================
@ -29,6 +32,30 @@ internal static class DumpInProgressRule
public static readonly TimeSpan MaxMarkerAge = TimeSpan.FromMinutes(10);
public static readonly TimeSpan FileQuietMs = TimeSpan.FromSeconds(30);
public static readonly TimeSpan MaxHold = TimeSpan.FromMinutes(15);
public enum Hold
{
/// <summary>No dump in progress: the kill checks run.</summary>
None,
/// <summary>A dump is in progress: hold off the kills.</summary>
Holding,
/// <summary>Signs of a dump, but held for MaxHold already: the kill checks run.</summary>
Expired,
}
/// <summary>
/// <see cref="IsDumping"/>, capped: <paramref name="holdSinceUtc"/> is when the launcher first
/// held this client (null = not held yet). The launcher keeps that time while the result is
/// Holding or Expired and forgets it on None, so an expired hold does not start again.
/// </summary>
public static Hold Decide(string? logTail, DateTime logLastWriteUtc, DateTime? newestOomDumpWriteUtc,
DateTime? holdSinceUtc, DateTime nowUtc)
{
if (!IsDumping(logTail, logLastWriteUtc, newestOomDumpWriteUtc, nowUtc)) return Hold.None;
if (holdSinceUtc is DateTime since && nowUtc - since >= MaxHold) return Hold.Expired;
return Hold.Holding;
}
/// <summary>
/// True while the launcher must not kill the client for a silent log.