mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8148813: Windows os::check_heap needs more information
Added ring buffer to log info while walking the heap Reviewed-by: mgronlun, dholmes, ccheung
This commit is contained in:
parent
634a7fdebc
commit
1bcb5e5156
1 changed files with 22 additions and 1 deletions
|
@ -5250,6 +5250,12 @@ int os::fork_and_exec(char* cmd) {
|
||||||
|
|
||||||
static int mallocDebugIntervalCounter = 0;
|
static int mallocDebugIntervalCounter = 0;
|
||||||
static int mallocDebugCounter = 0;
|
static int mallocDebugCounter = 0;
|
||||||
|
|
||||||
|
// For debugging possible bugs inside HeapWalk (a ring buffer)
|
||||||
|
#define SAVE_COUNT 8
|
||||||
|
static PROCESS_HEAP_ENTRY saved_heap_entries[SAVE_COUNT];
|
||||||
|
static int saved_heap_entry_index;
|
||||||
|
|
||||||
bool os::check_heap(bool force) {
|
bool os::check_heap(bool force) {
|
||||||
if (++mallocDebugCounter < MallocVerifyStart && !force) return true;
|
if (++mallocDebugCounter < MallocVerifyStart && !force) return true;
|
||||||
if (++mallocDebugIntervalCounter >= MallocVerifyInterval || force) {
|
if (++mallocDebugIntervalCounter >= MallocVerifyInterval || force) {
|
||||||
|
@ -5270,13 +5276,28 @@ bool os::check_heap(bool force) {
|
||||||
if (HeapLock(heap) != 0) {
|
if (HeapLock(heap) != 0) {
|
||||||
PROCESS_HEAP_ENTRY phe;
|
PROCESS_HEAP_ENTRY phe;
|
||||||
phe.lpData = NULL;
|
phe.lpData = NULL;
|
||||||
|
memset(saved_heap_entries, 0, sizeof(saved_heap_entries));
|
||||||
|
saved_heap_entry_index = 0;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
while (HeapWalk(heap, &phe) != 0) {
|
while (HeapWalk(heap, &phe) != 0) {
|
||||||
|
count ++;
|
||||||
if ((phe.wFlags & PROCESS_HEAP_ENTRY_BUSY) &&
|
if ((phe.wFlags & PROCESS_HEAP_ENTRY_BUSY) &&
|
||||||
!HeapValidate(heap, 0, phe.lpData)) {
|
!HeapValidate(heap, 0, phe.lpData)) {
|
||||||
tty->print_cr("C heap has been corrupted (time: %d allocations)", mallocDebugCounter);
|
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);
|
tty->print_cr("corrupted block near address %#x, length %d, count %d", phe.lpData, phe.cbData, count);
|
||||||
HeapUnlock(heap);
|
HeapUnlock(heap);
|
||||||
fatal("corrupted C heap");
|
fatal("corrupted C heap");
|
||||||
|
} else {
|
||||||
|
// Save previous seen entries in a ring buffer. We have seen strange
|
||||||
|
// heap corruption fatal errors that produced mdmp files, but when we load
|
||||||
|
// these mdmp files in WinDBG, "!heap -triage" shows no error.
|
||||||
|
// We can examine the saved_heap_entries[] array in the mdmp file to
|
||||||
|
// diagnose such seemingly spurious errors reported by HeapWalk.
|
||||||
|
saved_heap_entries[saved_heap_entry_index++] = phe;
|
||||||
|
if (saved_heap_entry_index >= SAVE_COUNT) {
|
||||||
|
saved_heap_entry_index = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue