UNEXPECTED_KERNEL_MODE_TRAP, the blue screen, explained and fixed

This stop code (0x0000007F) means the processor generated a trap, an emergency signal, that the kernel was not able to handle. The first parameter says which trap: 0 is a divide-by-zero, 4 an overflow, 6 an invalid instruction, and 8, the one most often reported, a double fault, where handling the first fault caused a second. Double faults in particular point at hardware: failing RAM, an overheating or overclocked CPU, or a corrupted kernel stack.

The fix, in order

  1. Remove all overclocking. Load BIOS/UEFI defaults, including RAM at its rated speed rather than an aggressive XMP profile, and retest. Trap errors are the CPU reporting that it executed something impossible, and marginal clocks make impossible things happen.
  2. Test the RAM thoroughly. Windows Memory Diagnostic first, then multiple passes overnight, then one stick at a time. A double fault from a corrupt stack in bad memory is a textbook cause of this code.
  3. Check temperatures and cooling. Confirm cooler mounting and fan or pump function; watch CPU temperature under the workload that triggers the crash. Thermal faults produce invalid-instruction and double-fault traps.
  4. Update BIOS/UEFI and chipset drivers. Microcode and platform fixes address real trap-handling errata. Use only the board or PC maker’s files.
  5. Repair system files. DISM /Online /Cleanup-Image /RestoreHealth, then sfc /scannow. A damaged kernel or driver binary can contain the invalid instruction the CPU objected to.
  6. Update or roll back recently changed drivers. If the code arrived with a new driver, Device Manager → Roll Back. Drivers execute in kernel mode and can absolutely set the trap off.
Back up your data. This code leans hardware more than most. If a component is deteriorating, the window between “crashes sometimes” and “does not boot” can be short.

If it still happens

If traps continue at stock settings with passing extended memory tests, good temperatures, and current firmware, suspect the CPU or motherboard. Event logs will not settle it; swapping in known-good parts, typically at a repair shop, is the definitive test. Keep notes of the first parameter from each crash, a consistent 8 (double fault) versus rotating values helps that diagnosis.

Common questions

What is a double fault, the parameter 8 I keep seeing? When the CPU hits a fault, it calls a handler. If it faults again while trying to handle the first one, that is a double fault, and there is no safe way to continue. Bad RAM corrupting the kernel stack is the classic reason the handler itself fails, which is why memory testing is step two on this page.

Can a virus cause UNEXPECTED_KERNEL_MODE_TRAP? Malware does not produce CPU traps directly. A rootkit that corrupts kernel structures can contribute indirectly, but the overwhelming majority of cases are hardware or driver faults. Run a scan for peace of mind after the hardware checks, not instead of them.

Related errors

MACHINE_CHECK_EXCEPTION · KMODE_EXCEPTION_NOT_HANDLED · WHEA_UNCORRECTABLE_ERROR · MEMORY_MANAGEMENT