src/os/windows/vm/os_windows.cpp

Print this page




4987     CloseHandle(pi.hThread);
4988 
4989     return (int)exit_code;
4990   } else {
4991     return -1;
4992   }
4993 }
4994 
4995 //--------------------------------------------------------------------------------------------------
4996 // Non-product code
4997 
4998 static int mallocDebugIntervalCounter = 0;
4999 static int mallocDebugCounter = 0;
5000 bool os::check_heap(bool force) {
5001   if (++mallocDebugCounter < MallocVerifyStart && !force) return true;
5002   if (++mallocDebugIntervalCounter >= MallocVerifyInterval || force) {
5003     // Note: HeapValidate executes two hardware breakpoints when it finds something
5004     // wrong; at these points, eax contains the address of the offending block (I think).
5005     // To get to the exlicit error message(s) below, just continue twice.
5006     HANDLE heap = GetProcessHeap();
5007     { HeapLock(heap);




5008       PROCESS_HEAP_ENTRY phe;
5009       phe.lpData = NULL;
5010       while (HeapWalk(heap, &phe) != 0) {
5011         if ((phe.wFlags & PROCESS_HEAP_ENTRY_BUSY) &&
5012             !HeapValidate(heap, 0, phe.lpData)) {
5013           tty->print_cr("C heap has been corrupted (time: %d allocations)", mallocDebugCounter);
5014           tty->print_cr("corrupted block near address %#x, length %d", phe.lpData, phe.cbData);
5015           fatal("corrupted C heap");
5016         }
5017       }
5018       DWORD err = GetLastError();
5019       if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) {
5020         fatal(err_msg("heap walk aborted with error %d", err));
5021       }
5022       HeapUnlock(heap);
5023     }
5024     mallocDebugIntervalCounter = 0;
5025   }
5026   return true;
5027 }




4987     CloseHandle(pi.hThread);
4988 
4989     return (int)exit_code;
4990   } else {
4991     return -1;
4992   }
4993 }
4994 
4995 //--------------------------------------------------------------------------------------------------
4996 // Non-product code
4997 
4998 static int mallocDebugIntervalCounter = 0;
4999 static int mallocDebugCounter = 0;
5000 bool os::check_heap(bool force) {
5001   if (++mallocDebugCounter < MallocVerifyStart && !force) return true;
5002   if (++mallocDebugIntervalCounter >= MallocVerifyInterval || force) {
5003     // Note: HeapValidate executes two hardware breakpoints when it finds something
5004     // wrong; at these points, eax contains the address of the offending block (I think).
5005     // To get to the exlicit error message(s) below, just continue twice.
5006     HANDLE heap = GetProcessHeap();
5007 
5008     // If we fail to lock the heap, then gflags.exe has been used
5009     // or some other special heap flag has been set that prevents
5010     // locking. We don't try to walk a heap we can't lock.
5011     if (HeapLock(heap) != 0) { 
5012       PROCESS_HEAP_ENTRY phe;
5013       phe.lpData = NULL;
5014       while (HeapWalk(heap, &phe) != 0) {
5015         if ((phe.wFlags & PROCESS_HEAP_ENTRY_BUSY) &&
5016             !HeapValidate(heap, 0, phe.lpData)) {
5017           tty->print_cr("C heap has been corrupted (time: %d allocations)", mallocDebugCounter);
5018           tty->print_cr("corrupted block near address %#x, length %d", phe.lpData, phe.cbData);
5019           fatal("corrupted C heap");
5020         }
5021       }
5022       DWORD err = GetLastError();
5023       if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) {
5024         fatal(err_msg("heap walk aborted with error %d", err));
5025       }
5026       HeapUnlock(heap);
5027     }
5028     mallocDebugIntervalCounter = 0;
5029   }
5030   return true;
5031 }