Skip to content

Commit 6f8f28e

Browse files
committed
8294160: misc crash dump improvements
Reviewed-by: dholmes, vlivanov
1 parent 8873192 commit 6f8f28e

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

src/hotspot/os/posix/signals_posix.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,7 @@ int JVM_HANDLE_XXX_SIGNAL(int sig, siginfo_t* info,
627627
#ifndef ZERO
628628
// Check for UD trap caused by NOP patching.
629629
// If it is, patch return address to be deopt handler.
630-
if (!signal_was_handled) {
631-
address pc = os::Posix::ucontext_get_pc(uc);
632-
assert(pc != NULL, "");
630+
if (!signal_was_handled && pc != NULL && os::is_readable_pointer(pc)) {
633631
if (NativeDeoptInstruction::is_deopt_at(pc)) {
634632
CodeBlob* cb = CodeCache::find_blob(pc);
635633
if (cb != NULL && cb->is_compiled()) {

src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp

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

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

src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp

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

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

src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp

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

@@ -456,7 +462,7 @@ void os::print_tos_pc(outputStream *st, const void *context) {
456462
// Note: it may be unsafe to inspect memory near pc. For example, pc may
457463
// point to garbage if entry point in an nmethod is corrupted. Leave
458464
// this at the end, and hope for the best.
459-
address pc = (address)uc->REG_PC;
465+
address pc = os::fetch_frame_from_context(uc).pc();
460466
print_instructions(st, pc, sizeof(char));
461467
st->cr();
462468
}

src/hotspot/share/oops/method.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2323,6 +2323,8 @@ bool Method::is_valid_method(const Method* m) {
23232323
} else if ((intptr_t(m) & (wordSize-1)) != 0) {
23242324
// Quick sanity check on pointer.
23252325
return false;
2326+
} else if (!os::is_readable_range(m, m + 1)) {
2327+
return false;
23262328
} else if (m->is_shared()) {
23272329
return CppVtables::is_valid_shared_method(m);
23282330
} else if (Metaspace::contains_non_shared(m)) {

0 commit comments

Comments
 (0)