windbg-user-heap-corruption-investigation
Skill469 starsChanged 36 days agoMITView on GitHub
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.
In this repository11 other files it gives its agents.
- windbg-diagnostic-methodSkill
- windbg-kernel-bugcheck-triageSkill
- windbg-kernel-irp-lifecycle-triageSkill
- windbg-kernel-lock-deadlock-triageSkill
- windbg-kernel-verifier-triageSkill
- windbg-user-exception-triageSkill
- windbg-user-mutex-held-across-co-awaitSkill
- windbg-user-ttd-reverse-debugging-triageSkill
- windbg-user-virtual-memory-exhaustionSkill
- windbg-user-wait-chain-analysisSkill
- sample-skillSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Load
windbg-diagnostic-methodfirst: if it is not already loaded in this conversation, and apply it throughout for evidence ranking, … - Very specific: line 15
Look for STATUS_HEAP_CORRUPTION (0xC0000374), Application Verifier stops, or failures in heap allocate/free/reallocate paths in an …
- Very specific: line 90
Do not change an existing application's verification policy without approval.
- Very specific: line 91
If a user-mode TTD trace is available, use windbg-user-ttd-reverse-debugging-triage to find the relevant mutation or free.
- Distinctive: line 103
Keep allocation and deallocation compatible across DLL/API boundaries.
- Very specific: line 121
Follow FEEDBACK.md and report reviewed, sanitized feedback to WinDbg-Feedback.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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
.exr -1
.ecxr
!analyze -v
kRecord 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 <frame> 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
!heap -p -a <address>
!avrf -hp -a <address>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 <address> L<size> and disassembly around the access.
Fill patterns and plausible pointers are clues, not causal proof. Correlate with
source, history, or a repro and trace the ownership transition.
4. Obtain stronger evidence if necessary
With user approval, enable full Page Heap for a named test executable:
gflags /p /enable target.exe /fullRestart that process and reproduce under the debugger. Application Verifier heap checks can also be configured for that test executable. Explain memory overhead, timing changes, and potential deliberate stops before doing this. Record the previous settings and restore them when finished; if Page Heap was newly enabled for this test, disable it with:
gflags /p /disable target.exeDo not change an existing application's verification policy without approval.
If a user-mode TTD trace is available, use windbg-user-ttd-reverse-debugging-triage to
find the relevant mutation or free.
Fix patterns
- Enforce the actual lifetime contract with ownership types or explicit acquire/release rules. Shared ownership is appropriate only when the design genuinely has multiple owners.
- Synchronize shared state separately:
shared_ptrownership does not make a concurrently modified cache or pointed-to object thread-safe. - Size buffers and check arithmetic, lengths, and terminators; use bounds-aware containers where appropriate.
- Keep allocation and deallocation compatible across DLL/API boundaries.
Validation
Establish the affected block and supported corruption class, name the path that violated bounds or ownership, and distinguish the detector from the writer. Exercise the fix with the same instrumentation and relevant concurrency/load. Report unresolved writer history rather than presenting a guessed fix as proven.
References
- Application Verifier stop definitions
- Heap extension
- Application Verifier extension
- GFlags and Page Heap
Feedback
Follow FEEDBACK.md and report reviewed, sanitized feedback to
WinDbg-Feedback.
Include windbg-user-heap-corruption-investigation and the package version from
plugin.json; no automatic dump, source, or transcript upload.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

