What KERNEL_MODE_HEAP_CORRUPTION means
Bug check 0x13A means the kernel-mode heap manager detected corruption in a heap. Microsoft’s reference describes the first parameter as the type of corruption, such as a buffer overrun, a buffer underrun, a block used after it was freed, or a corrupted free list. All of these usually trace back to code that wrote outside the memory it owned, which is why drivers are the first suspect.
Common causes
- A driver that writes past the end of, or before the start of, a memory block
- A driver that uses memory after releasing it, or releases it twice
- Recently installed or updated drivers, especially after hardware changes
- Faulty RAM or unstable memory settings that corrupt data in memory
How to fix KERNEL_MODE_HEAP_CORRUPTION
Work through these in order and test after each one. Stopping as soon as the crashes stop tells you which change mattered.
- Undo the most recent change. If the blue screens began after a Windows update, a new driver or new software, remove that change first. Uninstall the update from Settings, Windows Update, Update history, or roll a driver back in Device Manager (right-click the device, Properties, Driver, Roll Back Driver). Heap corruption often begins right after hardware or drivers change.
- Note the file name on the blue screen. If the screen shows a line such as "What failed" followed by a .sys file, write it down. Searching that file name shows which driver it belongs to, which tells you what to update or remove. The named file is the code that crashed, which is not always the root cause.
- Return the PC to stock settings. Reset the BIOS to defaults, then leave XMP or EXPO, CPU or GPU overclocks and undervolts (including per-core offsets such as Curve Optimizer) switched off while you test. If the crashes stop, re-enable one setting at a time to find the unstable one.
- Test the memory. Run Windows Memory Diagnostic (search for it in Start) for a quick check, then MemTest86 for several passes if the crashes continue. Any error points to a faulty stick or slot, or to memory settings the hardware cannot run reliably.
- Repair Windows system files. Open Terminal (Admin) and run
sfc /scannow. If it reports damage it could not repair, runDISM /Online /Cleanup-Image /RestoreHealth, restart, and runsfc /scannowonce more.
Reading the crash evidence for 0x13A
Microsoft’s reference gives the first parameter as the type of heap corruption, the second as the heap that reported it, and the third as the address where it was detected. The first parameter is the one to note, because it tells you how the heap was damaged.
Windows normally saves a small dump in C:\Windows\Minidump. If several crashes show the same first parameter and the same driver on the stack, that driver is the leading suspect.
| First parameter | What Microsoft describes | What it suggests |
|---|---|---|
| 0x3 or 0x4 | One or more corrupt entry headers | Memory was overwritten near a block |
| 0x6 | Corruption consistent with a buffer overrun | Code wrote past the end of a block |
| 0x7 | Corruption consistent with a buffer underrun | Code wrote before the start of a block |
| 0xB | Error consistent with using a block after freeing it | Use after free |
| 0xD | A corrupt free list, possibly use after free or an overflow of a nearby block | Memory misuse by a driver |
| 0x13 | The heap routine was passed a NULL heap handle | A driver calling the heap with a bad handle |
Source: Microsoft Learn: Bug Check 0x13A KERNEL_MODE_HEAP_CORRUPTION ↗
If the crashes continue after a clean memory test and a driver review, keep the minidump. A debugger can show the first parameter and the call stack, which names the code performing the faulty heap operation.
Not sure this is your code?
The stop code appears as text on the blue screen. If the PC restarted before you could read it, open Event Viewer, then Windows Logs, then System, and look for a BugCheck event with ID 1001. You can also search all stop codes.
Related guides
Other system file and kernel errors
- CRITICAL_PROCESS_DIED (0xEF)
- KERNEL_SECURITY_CHECK_FAILURE (0x139)
- REGISTRY_ERROR (0x51)
- RESOURCE_NOT_OWNED (0xE3)
