Skip to content

Commit 7fa6bc2

Browse files
committed
8294160: misc crash dump improvements
Reviewed-by: rrich Backport-of: 6f8f28e7566701b195ecc855f3e802cd7145e9aa
1 parent a7c0ed1 commit 7fa6bc2

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
128128
intptr_t* sp;
129129
intptr_t* fp;
130130
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
131+
if (!is_readable_pointer(epc)) {
132+
// Try to recover from calling into bad memory
133+
// Assume new frame has not been set up, the same as
134+
// compiled frame stack bang
135+
return fetch_compiled_frame_from_context(ucVoid);
136+
}
131137
return frame(sp, fp, epc);
132138
}
133139

@@ -342,7 +348,7 @@ void os::print_context(outputStream *st, const void *context) {
342348
// Note: it may be unsafe to inspect memory near pc. For example, pc may
343349
// point to garbage if entry point in an nmethod is corrupted. Leave
344350
// this at the end, and hope for the best.
345-
address pc = os::Posix::ucontext_get_pc(uc);
351+
address pc = os::fetch_frame_from_context(uc).pc();
346352
print_instructions(st, pc, 4/*native instruction size*/);
347353
st->cr();
348354
}

src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
142142
intptr_t* sp;
143143
intptr_t* fp;
144144
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
145+
if (!is_readable_pointer(epc)) {
146+
// Try to recover from calling into bad memory
147+
// Assume new frame has not been set up, the same as
148+
// compiled frame stack bang
149+
return fetch_compiled_frame_from_context(ucVoid);
150+
}
145151
return frame(sp, fp, epc);
146152
}
147153

@@ -579,7 +585,7 @@ void os::print_context(outputStream *st, const void *context) {
579585
// Note: it may be unsafe to inspect memory near pc. For example, pc may
580586
// point to garbage if entry point in an nmethod is corrupted. Leave
581587
// this at the end, and hope for the best.
582-
address pc = os::Posix::ucontext_get_pc(uc);
588+
address pc = os::fetch_frame_from_context(uc).pc();
583589
print_instructions(st, pc, sizeof(char));
584590
st->cr();
585591
}

src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
319319
intptr_t* sp;
320320
intptr_t* fp;
321321
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
322+
if (!is_readable_pointer(epc)) {
323+
// Try to recover from calling into bad memory
324+
// Assume new frame has not been set up, the same as
325+
// compiled frame stack bang
326+
return frame(sp + 1, fp, (address)*sp);
327+
}
322328
return frame(sp, fp, epc);
323329
}
324330

@@ -450,7 +456,7 @@ void os::print_context(outputStream *st, const void *context) {
450456
// Note: it may be unsafe to inspect memory near pc. For example, pc may
451457
// point to garbage if entry point in an nmethod is corrupted. Leave
452458
// this at the end, and hope for the best.
453-
address pc = (address)uc->REG_PC;
459+
address pc = os::fetch_frame_from_context(uc).pc();
454460
print_instructions(st, pc, sizeof(char));
455461
st->cr();
456462
}

src/hotspot/share/oops/method.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,8 @@ bool Method::is_valid_method(const Method* m) {
22782278
} else if ((intptr_t(m) & (wordSize-1)) != 0) {
22792279
// Quick sanity check on pointer.
22802280
return false;
2281+
} else if (!os::is_readable_range(m, m + 1)) {
2282+
return false;
22812283
} else if (m->is_shared()) {
22822284
return CppVtables::is_valid_shared_method(m);
22832285
} else if (Metaspace::contains_non_shared(m)) {

0 commit comments

Comments
 (0)