--- old/src/os/windows/vm/os_windows.cpp Thu May 1 11:49:40 2014 +++ new/src/os/windows/vm/os_windows.cpp Thu May 1 11:49:40 2014 @@ -5007,7 +5007,9 @@ { HeapLock(heap); PROCESS_HEAP_ENTRY phe; phe.lpData = NULL; + bool did_first_heapwalk_call = false; while (HeapWalk(heap, &phe) != 0) { + did_first_heapwalk_call = true; if ((phe.wFlags & PROCESS_HEAP_ENTRY_BUSY) && !HeapValidate(heap, 0, phe.lpData)) { tty->print_cr("C heap has been corrupted (time: %d allocations)", mallocDebugCounter); @@ -5016,7 +5018,15 @@ } } DWORD err = GetLastError(); - if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) { + + // - Always ignore the errors ERROR_NO_MORE_ITEMS and + // ERROR_CALL_NOT_IMPLEMENTED + // - Only ignore the error ERROR_INVALID_FUNCTION on + // the first call to HeapWalk + + if (err != ERROR_NO_MORE_ITEMS && + err != ERROR_CALL_NOT_IMPLEMENTED && + (did_first_heapwalk_call && err == ERROR_INVALID_FUNCTION)) { fatal(err_msg("heap walk aborted with error %d", err)); } HeapUnlock(heap);