Quick answer: Exception code 0xc0000374 is STATUS_HEAP_CORRUPTION. The Windows heap manager found its own bookkeeping damaged and ended the process. The damage was done earlier by other code (a buffer overrun, a use after free, a double free, or memory freed by a different allocator than the one that allocated it), so the faulting module ntdll.dll and the call stack at the crash are usually unrelated to the bug. Reproduce it with full page heap, Application Verifier or AddressSanitizer, which stop the program at the instruction that does the damage.
A player sends an Event Viewer entry that says ntdll.dll and 0xc0000374, or Visual Studio stops with “A heap has been corrupted”. The crash moves around: sometimes on level load, sometimes on quit, sometimes in a string copy that has worked for years. That wandering is the signature of heap corruption. This guide explains what the code means, why the crash site misleads, which mistakes cause it in native code and in engine games, how to get the tools to point at the real line, and what you can and cannot tell players.
The exact error
In Event Viewer > Windows Logs > Application, source Application Error, event ID 1000:
Faulting application name: MyGame.exe, version: 1.2.0.0, time stamp: 0x66f2a1b0
Faulting module name: ntdll.dll, version: 10.0.26100.2454, time stamp: 0x7cb6b6a8
Exception code: 0xc0000374
Fault offset: 0x0000000000116519
Faulting application path: C:\Program Files (x86)\Steam\steamapps\common\My Game\MyGame.exe
Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll
Under the Visual Studio debugger:
Unhandled exception at 0x00007FFB1A2F6519 (ntdll.dll) in MyGame.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00007FFB1A35F6B0).
In the debugger output window or WinDbg, just before the break:
Critical error detected c0000374
With the debug C runtime (a Debug build that uses malloc or new), the CRT may catch the same damage first and show its own dialog:
HEAP CORRUPTION DETECTED: after Normal block (#152) at 0x000001E4A3F1C2D0.
CRT detected that the application wrote to memory after end of heap buffer.
The addresses, offsets and block number are examples and differ on every machine and Windows build. The code and the module are the parts to match.
What the code means
STATUS_HEAP_CORRUPTION (“A heap has been corrupted”) is raised by the heap manager inside ntdll.dll. Every block that HeapAlloc, malloc or new hands out has a small header next to it, and free blocks are linked into lists. When the heap manager allocates or frees a block and finds a header or a list entry that fails its consistency checks, it reports a fatal error and terminates the process. For 64-bit processes this terminate-on-corruption behavior is on by default; a 32-bit process can opt in with HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0).
Three consequences follow, and they explain most of the confusion around this code:
- The faulting module is
ntdll.dllbecause that is where the check lives. Windows itself is not broken, and reinstalling it or running system file repair tools does not fix a bug in the game. - The crash happens at the next heap operation that touches the damaged block. That can be milliseconds or minutes after the bad write, on another thread, in code that did nothing wrong. The call stack in the dump shows the victim.
- Detection is not guaranteed. The same bug can also surface as 0xc0000005 (an access violation inside
ntdll.dllor in whatever code used the damaged memory), or go unnoticed and corrupt game data. A cluster of “random” crashes in one build often has one heap bug behind it. The access violation side is covered in How to Fix “Exception code: 0xc0000005” Access Violation Crashes in Your Game.
The heap manager reports this failure directly and ends the process. An in-process crash handler installed with SetUnhandledExceptionFilter may never be called, so do not count on your engine’s crash dialog or an in-game reporter appearing for this code. Dumps written by Windows Error Reporting are the dependable evidence.
What causes it
| Mistake | What happens in memory | Typical source in a game |
|---|---|---|
| Heap buffer overrun | A write past the end of a block lands on the next block’s header | Off-by-one loops, strcpy into a short buffer, a size computed in elements and used in bytes |
| Buffer underrun | A write before the start of a block damages its own header | Negative index, pointer arithmetic on the wrong base |
| Use after free | A stale pointer writes into memory that is now a free-list entry or belongs to someone else | Object destroyed while a callback, job or cached pointer still refers to it |
| Double free | The same block is returned to the heap twice | Two owners of one raw pointer, a copied struct that frees in its destructor |
| Mismatched allocator | A block is freed by a heap that did not allocate it | Memory allocated in one DLL and freed in another with a different C runtime; malloc paired with delete; a pointer that was never heap memory passed to free |
| Unsynchronized access | Two threads resize or free the same container at once | A loader thread appending to a list the main thread is clearing |
The mismatched allocator case deserves attention because it involves no out-of-bounds write at all. Each copy of the C runtime has its own heap bookkeeping. A DLL built with the static runtime (/MT) and an executable built with the DLL runtime (/MD), or two modules built with different Visual Studio versions, each carry their own copy. Memory from one copy’s malloc handed to another copy’s free is a documented cause of heap corruption.
Where it comes from in engine games
0xc0000374 means the Windows heap noticed. Unity and Unreal route most of their own allocations through their own allocators, and managed C# objects live on a garbage-collected heap, so damage there tends to show up as an access violation and not as this code. When an engine game reports STATUS_HEAP_CORRUPTION, look first at code that uses the Windows heap or the C runtime directly.
Unity
- Native plugins. Your own C or C++ plugin, or a third-party one, with any of the mistakes in the table.
- P/Invoke declarations that free memory they do not own. Under the .NET marshalling rules, a native function declared as returning
stringhands ownership of the returned pointer to the runtime, which frees it withCoTaskMemFree. If the native side returned a static buffer or amallocblock, that free corrupts the heap. - Buffer sizes and struct layouts that disagree. A struct declared in C# with a different size or field order than the C header, or a buffer passed to a function that writes more bytes than you allocated.
- Unsafe code and native containers. Bounds and use-after-dispose checks on
NativeArrayand its relatives run in the Editor. A standard release player is built without them, so an index error that raised an exception in the Editor becomes a silent out-of-bounds write in the build.
Unreal Engine
- Raw pointers and references into containers. A pointer or reference to a
TArrayelement that is kept across anAdd()dangles when the array reallocates. - Raw
UObject*members withoutUPROPERTY(). The garbage collector frees the object and the pointer keeps its old value. - Third-party libraries. A library that allocates with its own runtime and expects you to free with its function, or the reverse.
Any engine
Overlays, capture tools, RGB and peripheral utilities, and antivirus products inject DLLs into your process. Their allocations share the process heap with yours, and a bug in one of them produces this same event with your executable’s name on it. A report that only occurs with one such tool running is evidence for that.
What to ask a player for, and what a dump shows
Ask for two things:
- The Application Error entry copied as text. “Faulting module name” in Event Viewer: How to Read a Windows Game Crash Entry describes each field and how to copy it.
- A crash dump. Because in-process handlers are unreliable for this code, have the player enable Windows Error Reporting local dumps for your executable, as described in How to Collect Windows Crash Dumps From Players With WER LocalDumps, then reproduce the crash once.
Open the dump in WinDbg with the symbols for that exact build:
.symfix
.sympath+ C:\builds\1.2.0\symbols
.reload
!analyze -v
k
!heap -s -v
!heap -triage
!analyze -v confirms the code and often classifies the failure (for example as a double free). k prints the stack of the thread that tripped the check. !heap -s -v validates the heaps and reports damaged blocks, and !heap -triage searches the process’s heaps for failures, including in the low-fragmentation heap that plain validation skips.
Be clear about what an ordinary dump can give you. It shows which block was found damaged and which code was freeing or allocating at that moment. For a double free or a free of a bad pointer, that stack is the bug or its second half, and you are nearly done. For an overrun or a use after free, the writer is long gone. What you can still extract: the size of the damaged block and the bytes written over its header. A block size that matches one of your structures, or overwrite bytes that read as text or as a recognizable float pattern, narrows the search. Then reproduce it yourself with a tool that catches the write as it happens.
Making the crash happen at the bug
| Tool | Needs a rebuild | Catches |
|---|---|---|
Full page heap (gflags) | No | Overruns, use after free and double free on the Windows heap, at the faulting instruction |
| Application Verifier | No | The same heap checks plus handle and lock misuse, reported as verifier stops in a debugger |
| AddressSanitizer (MSVC) | Yes | Heap, stack and global overflows, use after free and double free, with allocation and free stacks |
| Debug CRT heap checks | Debug build | Writes just past or before a CRT block, found at the next check |
Full page heap
gflags.exe ships with the Debugging Tools for Windows. Full page heap places an inaccessible page at the end of each allocation, so the program stops immediately when it accesses memory beyond the block. From an elevated command prompt:
gflags /p /enable MyGame.exe /full
rem run the game under WinDbg or Visual Studio and reproduce
gflags /p
gflags /p /disable MyGame.exe
The setting is stored in the registry by image name, applies the next time the process starts, and stays until you disable it. gflags /p lists the programs it is enabled for. Full page heap uses at least a page of memory per allocation, so expect the game to run slowly and to need far more RAM; use a small test scene.
When the debugger stops on the access violation, the current stack is the code doing the damage. To see who allocated or freed the block involved, pass the faulting address to:
!heap -p -a 0x000001e4a3f1cff0
It prints whether the address is inside a page heap block, whether that block is allocated or was freed, and the recorded stack trace.
Application Verifier
Application Verifier (appverif.exe, in the Windows SDK) turns on the same heap verification with extra checks:
appverif -enable Heaps -for MyGame.exe
appverif -disable * -for MyGame.exe
Run the game under a debugger afterwards; a violation breaks in with a verifier stop that describes the problem.
AddressSanitizer
For code you can rebuild (your own engine, a native plugin, a GDExtension), compile with /fsanitize=address in Visual Studio 2019 version 16.9 or later. The report names the error (heap-buffer-overflow, heap-use-after-free, double-free), the bad access, and the stacks where the block was allocated and freed. It also covers stack and global buffers, which page heap cannot see.
Debug CRT
In a Debug build, ask the CRT to validate its heap on every allocation and free. It is slow, and it turns “some time later” into “at the next allocation”:
#include <crtdbg.h>
int main()
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF);
// ...
}
Engine allocators
Page heap only watches the Windows heap. For memory that goes through Unreal’s allocator, builds that include the stomp allocator accept the -stompmalloc command-line option, which applies the same guard-page idea to engine allocations. In Unity, reproduce in the Editor first, where the native container safety checks are active, and test native plugins outside the engine with AddressSanitizer.
Fixing what the tools find
Free memory with the allocator that produced it
Broken, when plugin.dll and the game use different copies of the C runtime:
// plugin.dll
extern "C" __declspec(dllexport) char* GetProfileName()
{
char* name = static_cast<char*>(malloc(64));
strcpy_s(name, 64, "Player One");
return name;
}
// game.exe
char* name = GetProfileName();
ShowName(name);
free(name); // a different heap frees the block
Fixed by exporting the matching release function, so allocation and free stay in one module:
// plugin.dll
extern "C" __declspec(dllexport) void FreeProfileName(char* name)
{
free(name);
}
// game.exe
char* name = GetProfileName();
ShowName(name);
FreeProfileName(name);
The same rule covers new with delete, new[] with delete[], and any library that documents its own free function.
Do not let the marshaller free native strings
Broken in C#, when the native function returns a pointer the caller must not free:
// C: const char* GetDeviceName(void); returns a static buffer
[DllImport("audioplugin")]
static extern string GetDeviceName();
Fixed by taking the pointer and copying the text yourself:
[DllImport("audioplugin")]
static extern IntPtr GetDeviceName();
string deviceName = Marshal.PtrToStringAnsi(GetDeviceName());
Make bounds explicit
Pass the buffer size across every native boundary and check it on the native side. Replace raw new[] buffers with std::vector and index with at() in test builds. In Unreal, re-fetch element pointers after any call that can grow the array, and hold objects through UPROPERTY() members, TWeakObjectPtr or TObjectPtr.
Give each block one owner
Double frees come from two pieces of code that each believe they own a pointer. Use std::unique_ptr for single ownership, delete or define the copy constructor of any class that frees in its destructor, and set raw pointers to nullptr after freeing when you cannot avoid them.
Confirming the fix
Run the reproduction again under the same tool that found the bug. A clean pass under full page heap or AddressSanitizer is evidence. A session that happened not to crash without the tool is not, because this class of bug depends on heap layout. After release, watch for the 0xc0000374 entries and the scattered ntdll.dll access violations in that build to fall together.
What players can try, and the limits
- Verify the game files (Steam: Properties > Installed Files > Verify integrity of game files).
- Remove mods and custom content, then test again.
- Turn off overlays and tools that inject into games for one run: Steam overlay, Discord overlay, RivaTuner and MSI Afterburner, capture software, RGB utilities.
- Update the graphics and audio drivers.
- If other programs on the same PC also crash at random, return any overclock or memory profile to defaults and run Windows Memory Diagnostic (
mdsched).
Be honest in your support reply about what these do. Steps 2 and 3 help when the corrupting code belongs to a mod or an injected DLL. Step 1 helps when a damaged data file sends your loader down a bad path, which is still a missing bounds check on your side. If the crash appears for many players in the same situation, no player-side step fixes it, and the useful thing a player can do is send the event text and a dump.
Where Bugnet fits
Bugnet does not capture native crashes as stack traces, does not process minidumps and does not symbolicate, and a process ended by the heap manager never gets to send a report. The dump workflow above is done with Microsoft’s tools. What Bugnet adds is the surrounding record. A player’s in-game report, or an automatically filed engine error from the same session, arrives with OS version, CPU, GPU, RAM and game version, which tells you which build’s symbols to load and whether the reports share hardware or a build. With the Unity SDK, managed exceptions and logged errors are captured through Application.logMessageReceived with recent log lines, and a native plugin that logs an error before things go wrong leaves that line in the report.
Once you have analyzed a dump, save the !analyze -v output or the copied Event Viewer entry as a text file and attach it to the report (text attachments up to 10 MB are accepted, binary dumps are not), so the evidence and the player’s description stay together. The bug reports docs cover attachments. Sessions killed this way are not counted as crashed in the crash-free session rate, so a good rate does not show these crashes are rare.
Related guides
- How to Fix “Exception code: 0xc0000005” Access Violation Crashes in Your Game
- “Faulting module name” in Event Viewer: How to Read a Windows Game Crash Entry
- How to Collect Windows Crash Dumps From Players With WER LocalDumps
- How to Fix Exception Code 0xc00000fd (Stack Overflow) Crashes in Your Game
- What Does Exception Code 0xe06d7363 Mean in a Game Crash?
Frequently asked questions
What does exception code 0xc0000374 mean?
It is STATUS_HEAP_CORRUPTION. The Windows heap manager found that the bookkeeping data of a heap had been damaged and ended the process. The damage was done earlier by code in the process, typically a buffer overrun, a use after free, a double free or memory freed by the wrong allocator.
Why is the faulting module ntdll.dll?
The heap manager lives in ntdll.dll, and that is where the consistency check failed. It does not mean Windows is damaged. The code that corrupted the heap ran earlier and belongs to the game, a plugin or a DLL injected into the game.
Why does the crash happen in a different place every time?
The bad write and its detection are separate events. The crash occurs at the next allocation or free that touches the damaged block, which depends on heap layout and timing, so the same bug surfaces in unrelated code on different runs.
How do I find the code that corrupted the heap?
Reproduce the crash with full page heap (gflags /p /enable MyGame.exe /full), Application Verifier or AddressSanitizer. These tools make the program stop at the instruction that writes out of bounds or uses freed memory, with the allocation stack available, so the debugger shows the real culprit.
Can a player fix a 0xc0000374 crash themselves?
Only when the corrupting code is not part of the game: removing mods, disabling overlays and other injected tools, or repairing a damaged install can help. If many players crash in the same situation, the bug is in the game and needs a patch.
With heap corruption the crash site is where the damage was found. Reproduce under full page heap or AddressSanitizer so the program stops at the write that does the damage, and fix that line.