Module crash_monitor

Module crash_monitor 

Source
Expand description

Out-of-process crash dump monitor for Windows.

§Architecture

Two-process pattern:

  • Main process: installs a VEH handler via crash-handler. On crash, the handler sends the crash context to the monitor over a Unix Domain Socket (IPC via minidumper).
  • Monitor process: same binary, launched with --crash-monitor. Runs a blocking minidumper::Server that receives crash contexts and writes .dmp files.

Why out-of-process? A crash may corrupt the heap or stack. Writing a minidump from inside the crashing process is unreliable. The monitor runs in a healthy isolated process and can safely call MiniDumpWriteDump even if the main process is badly corrupted.

§What this catches

  • Access violations (0xC0000005)
  • Heap corruption detected by heap manager
  • Rust panics that abort
  • Any exception that reaches the Vectored Exception Handler

§What this does NOT catch

  • __fastfail (int 0x29, exit code 0xC0000409) — the CPU traps directly to the kernel which terminates the process before returning to user mode. VEH is bypassed. Use WER LocalDumps for that (already configured via enable-wer-dumps.reg).

Dump location: C:\CrashDumps\agentmuxsrv\agentmuxsrv-<unix_ts>-<pid>.dmp Socket path: C:\CrashDumps\agentmuxsrv\monitor.sock

Structs§

CrashDumpHandler 🔒
CrashHandlerGuard
Guard that keeps the crash handler installed for the lifetime of the process. Dropping this guard uninstalls the VEH handler.

Constants§

DUMP_DIR 🔒
MSG_KIND_CRASH_PID 🔒
Message kind for sending the crashing process’s PID before a dump request. The monitor stores this PID and uses it in the dump filename.
SOCKET_PATH 🔒
Unix Domain Socket path used for crash-handler IPC.

Functions§

connect_with_retry 🔒
Try to connect to the server socket up to attempts times, sleeping delay between tries.
run_monitor
Entry point for the monitor process.
spawn_and_attach
Spawn a crash monitor child process and attach the VEH crash handler in this process.