Skip to main content

Module host_hang_dump

Module host_hang_dump 

Source
Expand description

SPEC_HOST_UI_THREAD_HANG_WATCHDOG_2026_08_14 §1–2 — capture evidence of a wedged host UI thread before anything (a person, usually) kills it.

On 2026-08-14 the host’s UI thread stopped pumping for ~16 minutes with a window open; it was killed by hand and nothing had captured a stack, so the deadlock’s cause is still unknown. A deadlock raises no exception, so the crash handler path can’t see it — the dump has to be taken EXTERNALLY by another process (what procdump -h does), here the launcher, which already supervises the host and probes its UI thread (ui_liveness).

Detection + dump only. Automatically killing and respawning a wedged host (spec §1’s last step) is a separate decision and not done here.

Structs§

HangDumpLatch
One dump per hang episode. Feed it ui_liveness::consecutive_misses() after each probe tick; a reply resets the misses to 0, which re-arms it.

Constants§

DUMP_LOCK_WAIT
How long a dump waits for another dump of this launcher to finish before it gives up. Under srv_liveness::WEDGE_DUMP_BUDGET, so a wedged srv is still killed on time.
DUMP_MAX_AGE_SECS
A dump older than this is deleted whenever a dump is written, even when fewer than the newest few are kept: a dump holds thread stacks, which can hold secrets that were in flight, so it is not kept for long. Age is read from the zero-padded seconds in the file’s name.
HOST_FILE_PREFIX 🔒
File-name prefix of the host’s hang dumps.
HOST_HANG_DUMP_MISSES
Dump once the UI thread has missed this many consecutive liveness probes. The probe runs every 60 s (supervisor/windows.rs), so this is a UI thread silent for at least ~1–2 minutes. Two, not one: a laptop sleep can cost at most one miss (the first probe after resume is answered).
MAX_DUMPS_KEPT
Keep at most this many hang dumps; older ones are deleted.
SRV_WEDGE_DUMPS_KEPT
Srv wedge dumps kept per instance.

Statics§

DUMP_WRITER 🔒
Held while a minidump is written. MiniDumpWriteDump is documented as unsafe to call from two threads of one process at once, and a host hang dump and a srv wedge dump can be asked for at the same time, so every writer in this module takes this first.

Functions§

dump_dir
%LOCALAPPDATA%\CrashDumps\agentmux-host-hang\<instance_key> — kept apart from crash dumps (a hang dump and a crash dump mean different things to triage), and one folder per instance (instance_key = the launcher’s data-dir hash) so pruning never deletes another running instance’s evidence (ReAgent P2 on #3913).
dump_dir_under
dump_dir with an explicit base. None for a key that isn’t a single plain path component — it is joined onto a path.
dump_file_name
Sortable by name: zero-padded timestamp first.
dump_file_name_with 🔒
<prefix><zero-padded seconds>-pid<pid>.dmp; the prefix ends with -.
dump_secs 🔒
The seconds a dump’s name carries: <prefix><zero-padded seconds>-pid<pid>.dmp.
plain_component 🔒
A key that is one plain path component: it is joined onto a path and put in a file name.
prune_old_dumps_at 🔒
prune_old_dumps_with at a given time. A file with this prefix whose name carries no readable time is counted for the newest keep and never deleted for its age.
prune_old_dumps_with 🔒
Delete the dumps with prefix in dir that are not among the newest keep or are older than DUMP_MAX_AGE_SECS. Best-effort.
srv_wedge_dir
%LOCALAPPDATA%\CrashDumps\agentmux-srv-wedge\<instance_key>: where a wedged srv’s dump goes. It is the user’s own profile folder, which Windows scopes to that user (and the system and administrators), so another account on the machine cannot read it; a machine-wide folder such as C:\CrashDumps is open to every local user, and a dump holds thread stacks that can hold secrets. One folder per instance, as for the host’s hang dumps. None when there is no LOCALAPPDATA or the key is not a single plain path component.
srv_wedge_dir_under
srv_wedge_dir with an explicit base.
srv_wedge_prefix
File-name prefix of one instance’s srv wedge dumps (agentmuxsrv-wedge-<instance_key>-), so pruning one instance’s dumps never deletes another running instance’s. None for a key that is not a single plain path component.
with_writer_lock 🔒
Run write once lock is free, waiting at most wait for it. A dump that cannot get the lock in time is not written (Err): the caller carries on, and whoever holds it is writing a dump already. A lock a panicked writer left poisoned is taken all the same: it guards no data.