8143233: [windows] Fixes to os::check_heap()
authorstuefe
Tue, 24 Nov 2015 15:58:26 -0500
changeset 34278 d0693c55b8a4
parent 34274 458a7bb38555
child 34279 92de270a7364
8143233: [windows] Fixes to os::check_heap() Reviewed-by: dholmes, ctornqvi
hotspot/src/os/windows/vm/os_windows.cpp
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Tue Nov 24 18:32:35 2015 +0000
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Tue Nov 24 15:58:26 2015 -0500
@@ -5254,7 +5254,13 @@
     // Note: HeapValidate executes two hardware breakpoints when it finds something
     // wrong; at these points, eax contains the address of the offending block (I think).
     // To get to the exlicit error message(s) below, just continue twice.
-    HANDLE heap = GetProcessHeap();
+    //
+    // Note:  we want to check the CRT heap, which is not necessarily located in the
+    // process default heap.
+    HANDLE heap = (HANDLE) _get_heap_handle();
+    if (!heap) {
+      return true;
+    }
 
     // If we fail to lock the heap, then gflags.exe has been used
     // or some other special heap flag has been set that prevents
@@ -5267,11 +5273,13 @@
             !HeapValidate(heap, 0, phe.lpData)) {
           tty->print_cr("C heap has been corrupted (time: %d allocations)", mallocDebugCounter);
           tty->print_cr("corrupted block near address %#x, length %d", phe.lpData, phe.cbData);
+          HeapUnlock(heap);
           fatal("corrupted C heap");
         }
       }
       DWORD err = GetLastError();
       if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) {
+        HeapUnlock(heap);
         fatal("heap walk aborted with error %d", err);
       }
       HeapUnlock(heap);