src/os/windows/vm/os_windows.cpp

Print this page




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 }
5028 
5029 
5030 bool os::find(address addr, outputStream* st) {
5031   // Nothing yet
5032   return false;
5033 }
5034 
5035 LONG WINAPI os::win32::serialize_fault_filter(struct _EXCEPTION_POINTERS* e) {
5036   DWORD exception_code = e->ExceptionRecord->ExceptionCode;
5037 
5038   if ( exception_code == EXCEPTION_ACCESS_VIOLATION ) {
5039     JavaThread* thread = (JavaThread*)ThreadLocalStorage::get_thread_slow();




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       bool did_first_heapwalk_call = false;
5011       while (HeapWalk(heap, &phe) != 0) {
5012         did_first_heapwalk_call = true;
5013         if ((phe.wFlags & PROCESS_HEAP_ENTRY_BUSY) &&
5014             !HeapValidate(heap, 0, phe.lpData)) {
5015           tty->print_cr("C heap has been corrupted (time: %d allocations)", mallocDebugCounter);
5016           tty->print_cr("corrupted block near address %#x, length %d", phe.lpData, phe.cbData);
5017           fatal("corrupted C heap");
5018         }
5019       }
5020       DWORD err = GetLastError();
5021 
5022       // - Always ignore the errors ERROR_NO_MORE_ITEMS and
5023       //   ERROR_CALL_NOT_IMPLEMENTED
5024       // - Only ignore the error ERROR_INVALID_FUNCTION on
5025       //   the first call to HeapWalk
5026 
5027       if (err != ERROR_NO_MORE_ITEMS &&
5028           err != ERROR_CALL_NOT_IMPLEMENTED &&
5029           (did_first_heapwalk_call && err == ERROR_INVALID_FUNCTION)) {
5030         fatal(err_msg("heap walk aborted with error %d", err));
5031       }
5032       HeapUnlock(heap);
5033     }
5034     mallocDebugIntervalCounter = 0;
5035   }
5036   return true;
5037 }
5038 
5039 
5040 bool os::find(address addr, outputStream* st) {
5041   // Nothing yet
5042   return false;
5043 }
5044 
5045 LONG WINAPI os::win32::serialize_fault_filter(struct _EXCEPTION_POINTERS* e) {
5046   DWORD exception_code = e->ExceptionRecord->ExceptionCode;
5047 
5048   if ( exception_code == EXCEPTION_ACCESS_VIOLATION ) {
5049     JavaThread* thread = (JavaThread*)ThreadLocalStorage::get_thread_slow();