What is 0xC0000374

 
Previous Next
STATUS_FAILED_STACK_SWITCH STATUS_SMARTCARD_WRONG_PIN

STATUS_HEAP_CORRUPTION

This error occurs when trying to allocate memory in a heap in which a corruption of the internal structure is detected. Usually the reason for this is that the program code previously allocated a block of memory and wrote more data into it than it requested when allocating. It is also possible that the size of the previously allocated block is zero. This is possible if the program does not always check the return results of internal or api functions.

Most applications allocate smaller blocks than the 64-KB minimum allocation granularity possible using page granularity functions such as VirtualAlloc and VirtualAllocExNuma. Allocating such a large area for relatively small allocations is not optimal from a memory usage and performance standpoint. To address this need, Windows provides a component called the heap manager, which manages allocations inside larger memory areas reserved using the page granularity memory allocation functions. The allocation granularity in the heap manager is relatively small: 8 bytes on 32-bit systems, and 16 bytes on 64-bit systems. The heap manager has been designed to optimize memory usage and performance in the case of these smaller allocations.

Heap STATUS_HEAP_CORRUPTION (0xC0000374)

The heap manager exists in two places: Ntdll.dll and Ntoskrnl.exe. The subsystem APIs (such as the Windows heap APIs) call the functions in Ntdll, and various executive components and device drivers call the functions in Ntoskrnl. Its native interfaces (prefixed with Rtl) are available only for use in internal Windows components or kernel-mode device drivers. The documented Windows API interfaces to the heap (prefixed with Heap) are forwarders to the native functions in Ntdll.dll. In addition, legacy APIs (prefixed with either Local or Global) are provided to support older Windows applications, which also internally call the heap manager, using some of its specialized interfaces to support legacy behavior. The C runtime (CRT) also uses the heap manager when using functions such as malloc, free, and the C++ new operator. The most common Windows heap functions are:

  • HeapCreate or HeapDestroy Creates or deletes, respectively, a heap. The initial reserved and committed size can be specified at creation.
  • HeapAlloc Allocates a heap block.
  • HeapFree Frees a block previously allocated with HeapAlloc.
  • HeapReAlloc Changes the size of an existing allocation (grows or shrinks an existing block).
  • HeapLock or HeapUnlock Controls mutual exclusion to the heap operations.
  • HeapWalk Enumerates the entries and regions in a heap.