hotspot/src/os/windows/vm/os_windows.cpp
changeset 34306 f64a5e6127f2
parent 34305 e399e6b44631
parent 34278 d0693c55b8a4
child 34621 7676bec20997
equal deleted inserted replaced
34305:e399e6b44631 34306:f64a5e6127f2
  5252   if (++mallocDebugCounter < MallocVerifyStart && !force) return true;
  5252   if (++mallocDebugCounter < MallocVerifyStart && !force) return true;
  5253   if (++mallocDebugIntervalCounter >= MallocVerifyInterval || force) {
  5253   if (++mallocDebugIntervalCounter >= MallocVerifyInterval || force) {
  5254     // Note: HeapValidate executes two hardware breakpoints when it finds something
  5254     // Note: HeapValidate executes two hardware breakpoints when it finds something
  5255     // wrong; at these points, eax contains the address of the offending block (I think).
  5255     // wrong; at these points, eax contains the address of the offending block (I think).
  5256     // To get to the exlicit error message(s) below, just continue twice.
  5256     // To get to the exlicit error message(s) below, just continue twice.
  5257     HANDLE heap = GetProcessHeap();
  5257     //
       
  5258     // Note:  we want to check the CRT heap, which is not necessarily located in the
       
  5259     // process default heap.
       
  5260     HANDLE heap = (HANDLE) _get_heap_handle();
       
  5261     if (!heap) {
       
  5262       return true;
       
  5263     }
  5258 
  5264 
  5259     // If we fail to lock the heap, then gflags.exe has been used
  5265     // If we fail to lock the heap, then gflags.exe has been used
  5260     // or some other special heap flag has been set that prevents
  5266     // or some other special heap flag has been set that prevents
  5261     // locking. We don't try to walk a heap we can't lock.
  5267     // locking. We don't try to walk a heap we can't lock.
  5262     if (HeapLock(heap) != 0) {
  5268     if (HeapLock(heap) != 0) {
  5265       while (HeapWalk(heap, &phe) != 0) {
  5271       while (HeapWalk(heap, &phe) != 0) {
  5266         if ((phe.wFlags & PROCESS_HEAP_ENTRY_BUSY) &&
  5272         if ((phe.wFlags & PROCESS_HEAP_ENTRY_BUSY) &&
  5267             !HeapValidate(heap, 0, phe.lpData)) {
  5273             !HeapValidate(heap, 0, phe.lpData)) {
  5268           tty->print_cr("C heap has been corrupted (time: %d allocations)", mallocDebugCounter);
  5274           tty->print_cr("C heap has been corrupted (time: %d allocations)", mallocDebugCounter);
  5269           tty->print_cr("corrupted block near address %#x, length %d", phe.lpData, phe.cbData);
  5275           tty->print_cr("corrupted block near address %#x, length %d", phe.lpData, phe.cbData);
       
  5276           HeapUnlock(heap);
  5270           fatal("corrupted C heap");
  5277           fatal("corrupted C heap");
  5271         }
  5278         }
  5272       }
  5279       }
  5273       DWORD err = GetLastError();
  5280       DWORD err = GetLastError();
  5274       if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) {
  5281       if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) {
       
  5282         HeapUnlock(heap);
  5275         fatal("heap walk aborted with error %d", err);
  5283         fatal("heap walk aborted with error %d", err);
  5276       }
  5284       }
  5277       HeapUnlock(heap);
  5285       HeapUnlock(heap);
  5278     }
  5286     }
  5279     mallocDebugIntervalCounter = 0;
  5287     mallocDebugIntervalCounter = 0;