--- name: windbg-user-heap-corruption-investigation description: 'Use when an app, service, or user-mode driver host heap fails or Application Verifier detects corruption; inspect history and bounds. Not for kernel pool corruption or ordinary OOM.' --- # Heap Corruption Investigation **Load `windbg-diagnostic-method` first** if it is not already loaded in this conversation, and apply it throughout for evidence ranking, hypothesis testing, confidence calibration, independent review, and report validation. This skill adds the bug-family-specific commands and evidence requirements. ## Detection and limits Look for `STATUS_HEAP_CORRUPTION` (`0xC0000374`), Application Verifier stops, or failures in heap allocate/free/reallocate paths in an application, service, or user-mode driver host such as an UMDF host process. A crash inside the allocator may be the first detection of an earlier bad write, not the faulty operation. Distinguish corruption from allocation failure; for the latter use `windbg-user-virtual-memory-exhaustion`. Allocation/free history depends on how the process was instrumented and which pages were captured. A missing history is a limitation, not proof of a leak or use-after-free. ## Workflow ### 1. Decode the stop ```text .exr -1 .ecxr !analyze -v k ``` Record the stop reason, corrupted block, corruption address, and the operation that detected the damage. If a verifier stop frame has parameter/local symbols, select it with `.frame /r ` and inspect `dv`; otherwise use the captured stop output and the documented stop definition. Do not assume one fixed parameter layout or a stop code shared by all verifier versions. ### 2. Recover available block history ```text !heap -p -a
!avrf -hp -a ``` The first command inspects a Page Heap allocation; the second searches available Application Verifier heap-operation history. Use `!heap -?` and `!avrf -?` to confirm support in the installed extension. On an uninstrumented dump these commands may not recover the history needed to identify the writer. Capture allocation and free stacks when present. Check the address is inside the user allocation rather than a header or neighboring block. ### 3. Test competing explanations | Hypothesis | Evidence to seek | |---|---| | Use-after-free | Confirmed free before a later access through a retained reference | | Double-free | Two ownership/completion paths freeing the same allocation | | Overrun/underrun | A write outside the allocated user bounds | | Wild write | Corrupted header or payload and a writer with an invalid target | | Allocation/free contract mismatch | Different allocator/deallocator or incorrect owning heap | Inspect bytes with `db L