8294160: misc crash dump improvements

Reviewed-by: dholmes, vlivanov
This commit is contained in:
Dean Long 2022-09-28 23:15:04 +00:00
parent 8873192433
commit 6f8f28e756
5 changed files with 24 additions and 6 deletions

View File

@ -627,9 +627,7 @@ int JVM_HANDLE_XXX_SIGNAL(int sig, siginfo_t* info,
#ifndef ZERO
// Check for UD trap caused by NOP patching.
// If it is, patch return address to be deopt handler.
if (!signal_was_handled) {
address pc = os::Posix::ucontext_get_pc(uc);
assert(pc != NULL, "");
if (!signal_was_handled && pc != NULL && os::is_readable_pointer(pc)) {
if (NativeDeoptInstruction::is_deopt_at(pc)) {
CodeBlob* cb = CodeCache::find_blob(pc);
if (cb != NULL && cb->is_compiled()) {

View File

@ -129,6 +129,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
intptr_t* sp;
intptr_t* fp;
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
if (!is_readable_pointer(epc)) {
// Try to recover from calling into bad memory
// Assume new frame has not been set up, the same as
// compiled frame stack bang
return fetch_compiled_frame_from_context(ucVoid);
}
return frame(sp, fp, epc);
}
@ -348,7 +354,7 @@ void os::print_tos_pc(outputStream *st, const void *context) {
// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::Posix::ucontext_get_pc(uc);
address pc = os::fetch_frame_from_context(uc).pc();
print_instructions(st, pc, 4/*native instruction size*/);
st->cr();
}

View File

@ -143,6 +143,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
intptr_t* sp;
intptr_t* fp;
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
if (!is_readable_pointer(epc)) {
// Try to recover from calling into bad memory
// Assume new frame has not been set up, the same as
// compiled frame stack bang
return fetch_compiled_frame_from_context(ucVoid);
}
return frame(sp, fp, epc);
}
@ -582,7 +588,7 @@ void os::print_tos_pc(outputStream *st, const void *context) {
// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::Posix::ucontext_get_pc(uc);
address pc = os::fetch_frame_from_context(uc).pc();
print_instructions(st, pc, sizeof(char));
st->cr();
}

View File

@ -320,6 +320,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
intptr_t* sp;
intptr_t* fp;
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
if (!is_readable_pointer(epc)) {
// Try to recover from calling into bad memory
// Assume new frame has not been set up, the same as
// compiled frame stack bang
return frame(sp + 1, fp, (address)*sp);
}
return frame(sp, fp, epc);
}
@ -456,7 +462,7 @@ void os::print_tos_pc(outputStream *st, const void *context) {
// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = (address)uc->REG_PC;
address pc = os::fetch_frame_from_context(uc).pc();
print_instructions(st, pc, sizeof(char));
st->cr();
}

View File

@ -2323,6 +2323,8 @@ bool Method::is_valid_method(const Method* m) {
} else if ((intptr_t(m) & (wordSize-1)) != 0) {
// Quick sanity check on pointer.
return false;
} else if (!os::is_readable_range(m, m + 1)) {
return false;
} else if (m->is_shared()) {
return CppVtables::is_valid_shared_method(m);
} else if (Metaspace::contains_non_shared(m)) {