Skip to content

How-ToRAM

UNEXPECTED_KERNEL_MODE_TRAP in Windows 11: Causes and How to Fix It

UNEXPECTED_KERNEL_MODE_TRAP (bug check 0x7F) means the processor raised a trap Windows couldn't catch, and Microsoft says faulty or mismatched hardware, especially memory, is the usual cause. Here's how to read the trap number and work through RAM, overclocks, PSU, BIOS, drivers, crash dumps and DISM and SFC.

By , Systems & Technical Editor

8 min read

UNEXPECTED_KERNEL_MODE_TRAP in Windows 11: Causes and How to Fix It

UNEXPECTED_KERNEL_MODE_TRAP is a blue screen stop code that points more firmly at hardware than most. Microsoft's reference page says it "typically occurs after you install faulty or mismatched hardware, especially memory, or if installed hardware fails". So if it started after you added RAM, swapped a part or turned on an overclock, you probably already have your first suspect. This guide explains what the code means, how to read the trap number that comes with it, and the order we'd work through the hardware and driver checks. The causes, tools and settings below come from Microsoft's own documentation, and the order of the checks is our advice.

What the error actually means

Microsoft lists UNEXPECTED_KERNEL_MODE_TRAP as bug check 0x7F (full value 0x0000007F). It means the processor generated a trap (a kind of exception) and the Windows kernel failed to catch it. Microsoft says the trap is one of two types:

  • A bound trap, which is a trap the kernel isn't permitted to catch.

  • A double fault, which is "a fault that occurred while processing an earlier fault, which always results in a system failure".

Microsoft gives two main causes for 0x7F. The first is hardware: faulty or mismatched hardware, especially memory, or hardware that has failed. The second is a kernel stack overflow, which can cause a double fault. Microsoft says this can happen "if multiple drivers are attached to the same stack", and gives the example of two file system filter drivers attached to the same stack.

If you've seen the error once and it hasn't come back, you may not need to do anything. Microsoft's support page says that in most cases when Windows 11 restarts unexpectedly, "the problem is resolved by the restart and no further action is needed". It's worth working through this guide when the same stop code keeps returning.

Step 1: Find the trap number

The first stop code parameter tells you which trap caused the crash, and it's the most useful clue 0x7F gives you. If the PC restarts before you can read the blue screen, open Event Viewer once Windows has booted and look in Windows Logs > System. Microsoft says the bug check event will list the four stop code parameters. Our Event Viewer guide shows how to filter the log.

Microsoft lists these as the most common trap numbers for parameter 1:

Parameter 1

Trap

What Microsoft says about it

0x00000000

Divide by Zero Error

A DIV instruction ran with a divisor of zero. Memory corruption, other hardware problems or software failures can cause it

0x00000004

Overflow

The processor called an interrupt handler while the overflow (OF) flag was set

0x00000005

Bounds Check Fault

A BOUND instruction found an operand outside its limits

0x00000006

Invalid Opcode

The processor tried to run an invalid instruction. Microsoft says "the most common cause of this error is hardware memory corruption"

0x00000008

Double Fault

An exception happened while the handler for an earlier exception was running

For a double fault (0x00000008), Microsoft names two common causes: a kernel stack overflow and a hardware problem. In practice, that means trap 0x8 can come from a driver or from a failing part, so it's worth doing both the hardware and driver checks below.

As a rough guide, if parameter 1 is 0x00000006 (Invalid Opcode), start with memory, because that's the cause Microsoft calls most common. If it's 0x00000008, check for recently added drivers and security or backup tools as well as hardware.

Step 2: Undo recent hardware changes

Because Microsoft ties 0x7F so closely to hardware, start with anything you've changed recently. Its troubleshooting steps say:

  • Remove new hardware. If you recently added hardware, remove it and see if the error comes back.

  • Replace failed parts. If existing hardware has failed, remove or replace it. Microsoft suggests running the hardware diagnostics your system manufacturer supplies to find which part has failed.

  • Check storage compatibility. Confirm that your drives and drive controllers are compatible with your version of Windows.

If you've just added a RAM kit, the most useful test is to go back to the old memory, or to run with one stick at a time. That's our advice rather than Microsoft's, but it follows from Microsoft's point about faulty or mismatched memory.

Step 3: Remove overclocks, including memory profiles

Microsoft says overclocking, "setting the CPU to run at speeds above the rated specification", can cause this error. If you've overclocked the PC, it says to return the CPU to its default clock speed. It also suggests disabling BIOS memory caching to try to fix the problem, if your BIOS has that option.

We'd go a step further and treat memory profiles the same way, because XMP and EXPO are a form of memory overclock (our advice). If the crashes started after you enabled one, set the memory back to default in the BIOS and see if they stop. Our guide to crashes after enabling XMP or EXPO covers this in more detail. If you're not sure what has been changed in the BIOS, clearing CMOS puts the BIOS settings back to their defaults.

Step 4: Test your memory

Microsoft says "Faulty or mismatched memory can cause this bug check" and recommends using the memory diagnostic program in Windows to test all of the system memory.

As a second opinion, you can also use MemTest86 (our suggestion). Our MemTest86 guide explains how to run it, and Windows Memory Diagnostic vs MemTest86 compares the two. In our view, errors at default memory settings are a strong reason to replace the faulty stick or try another slot.

Step 5: Think about the motherboard and power supply

Microsoft's hardware checklist also mentions the parts that are hardest to test at home. It says the motherboard "might have issues, such as a scratched trace or a defective component", and that "A failing power supply can also cause issues."

You can't easily check a board for damaged traces, but you can look for the signs of a failing PSU. Our guides on how to tell if a PSU is failing and how to test a power supply walk through what to look for. If you have a known-good spare PSU, swapping it in is often the quickest test (our advice).

Step 6: Update the BIOS and key drivers

On the software side, Microsoft says to check with the hardware manufacturer for updates to the ACPI/BIOS, the hard disk controller and network cards. It also says to check the System log in Event Viewer for other errors that might help identify the device or driver involved.

For the BIOS, only use files from your motherboard or PC maker's own support page, and follow our guide to updating the BIOS safely (our advice). For drivers, Microsoft's Device Manager page explains how to update a driver from Device Manager, and how to use Roll Back Driver on the device's Driver tab. You must be signed in with administrator permissions to roll back drivers.

Step 7: Remove a new driver or conflicting software

Microsoft says that if the error started after you installed a new or updated device driver, you should remove or replace that driver. Because a double fault can come from several drivers attached to the same stack, we'd also think about software that installs its own low-level drivers, such as antivirus and backup tools.

If the error appeared while upgrading Windows, Microsoft says incompatible software might be the cause, giving the examples of "a device driver, a system service, a virus scanner, or a backup tool". It says to remove third-party drivers and system services and disable virus scanners before the upgrade, then contact the software makers for updates. It also says to make sure the latest Windows updates are installed.

If the PC crashes during startup, use Safe Mode. Microsoft's startup settings page explains the route: open the Windows Recovery Environment, then select Troubleshoot > Advanced options > Startup Settings > Restart. When the PC restarts, press 4 or F4 for Safe Mode, or 5 or F5 for Safe Mode with Networking. Microsoft says Safe Mode "starts Windows in a basic state, using a limited set of files and drivers". If your drive is encrypted, you'll need your BitLocker key. Microsoft's reference page for 0x7F also mentions the Recovery Console and Last Known Good Configuration, but these are older tools, so we'd use Safe Mode instead. If you're not sure whether Safe Mode or a clean boot is the better test, see Safe Mode vs clean boot.

Step 8: Read the crash dump

If the checks so far haven't found the cause, the crash dump can show you what was running. For 0x7F, Microsoft's debugging advice is to always begin with !analyze -v, examine the output and the faulting code, and "Look for reoccurring trends in multiple dumps". Microsoft's advanced troubleshooting guide says small memory dumps are saved in %SystemRoot%\Minidump and kernel or complete dumps in %SystemRoot%\MEMORY.DMP. You can choose the dump type in System Properties under Startup and Recovery (Write debugging information).

If several dumps name the same driver, that's your suspect. If they point to different places each time, that's a sign to focus on hardware, especially memory (our advice). Our WinDbg minidump guide shows how to open the files, and our pick of free BSOD analysis tools covers simpler options.

Step 9: Repair Windows itself

If the hardware tests pass and no driver stands out, check that Windows' own files are intact. Microsoft says to run DISM.exe /Online /Cleanup-image /Restorehealth first, then sfc /scannow, both from an elevated (Run as administrator) Command Prompt. Microsoft says SFC "will scan all protected system files and replace corrupted files with a cached copy". Our DISM and SFC guide walks through both.

Microsoft's support page also suggests keeping 10% to 15% of your drive free, installing the latest Windows updates and, if nothing else works, restoring Windows from a system restore point or another recovery option.

Quick checklist

  1. Note parameter 1 (the trap number) from the blue screen or Event Viewer.

  2. Remove recently added hardware, especially RAM.

  3. Return the CPU to default clocks and turn off XMP or EXPO.

  4. Test the memory with Windows Memory Diagnostic or MemTest86.

  5. Consider the PSU and motherboard if memory passes.

  6. Update the BIOS and key drivers, or roll back a recent driver.

  7. Remove new drivers, antivirus or backup tools, using Safe Mode if needed.

  8. Read the crash dumps with !analyze -v and look for patterns.

  9. Run DISM, then SFC.

For other stop codes, start with our Windows 11 blue screen guide. If your crashes point to hardware errors more generally, see WHEA_UNCORRECTABLE_ERROR and MEMORY_MANAGEMENT. Driver-led crashes are covered in our KMODE_EXCEPTION_NOT_HANDLED guide.

The bottom line

UNEXPECTED_KERNEL_MODE_TRAP (bug check 0x7F) means the processor raised a trap that the Windows kernel didn't catch, and Microsoft says it's typically caused by faulty, mismatched or failed hardware, especially memory. Start with the trap number in parameter 1, then undo recent hardware changes and overclocks, including XMP or EXPO. Test the RAM, and consider the PSU and motherboard if it passes. Then update the BIOS and drivers, remove new drivers or security and backup tools, read the crash dumps for patterns, and finish with DISM and SFC.

Sources

  1. 01Bug check 0x7F: UNEXPECTED_KERNEL_MODE_TRAP (Microsoft Learn)
  2. 02Advanced troubleshooting for stop or blue screen errors (Microsoft Learn)
  3. 03Analyze bug check (stop code error) data (Microsoft Learn)
  4. 04Troubleshooting Windows unexpected restarts and stop code errors (Microsoft Support)
  5. 05Windows startup settings (Microsoft Support)
  6. 06Update drivers through Device Manager in Windows (Microsoft Support)
  7. 07Use the System File Checker tool to repair missing or corrupted system files (Microsoft Support)

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

How to Use AMD Radeon Anti-Lag and Anti-Lag 2 to Cut Input Lag

How-To

How to Use AMD Radeon Anti-Lag and Anti-Lag 2 to Cut Input Lag

AMD has two latency features with almost the same name. Using AMD's documentation and driver release notes, we explain Radeon Anti-Lag vs Anti-Lag 2, which Radeon cards and Ryzen APUs support each, how to turn them on per game or with HYPR-RX, and how to use AMD's Latency Monitor.

Marcus Thorne5 min

How to Use Automatic GPU Tuning in the NVIDIA App

How-To

How to Use Automatic GPU Tuning in the NVIDIA App

The NVIDIA App can overclock a GeForce RTX graphics card for you. Using NVIDIA's own documentation, we show where to find Automatic Tuning, how to run the 10 to 20-minute scan, how to set voltage, power, temperature and fan targets, and how to check the result is stable.

Marcus Thorne5 min