提交 4e146239 编写于 作者: N ngasson

8209413: AArch64: NPE in clhsdb jstack command

Reviewed-by: aph
上级 e32b343d
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2019, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -372,15 +372,9 @@ void MacroAssembler::set_last_Java_frame(Register last_java_sp,
Register last_java_fp,
address last_java_pc,
Register scratch) {
if (last_java_pc != NULL) {
adr(scratch, last_java_pc);
} else {
// FIXME: This is almost never correct. We should delete all
// cases of set_last_Java_frame with last_java_pc=NULL and use the
// correct return address instead.
adr(scratch, pc());
}
assert(last_java_pc != NULL, "must provide a valid PC");
adr(scratch, last_java_pc);
str(scratch, Address(rthread,
JavaThread::frame_anchor_offset()
+ JavaFrameAnchor::last_Java_pc_offset()));
......@@ -397,7 +391,7 @@ void MacroAssembler::set_last_Java_frame(Register last_java_sp,
} else {
InstructionMark im(this);
L.add_patch_at(code(), locator());
set_last_Java_frame(last_java_sp, last_java_fp, (address)NULL, scratch);
set_last_Java_frame(last_java_sp, last_java_fp, pc() /* Patched later */, scratch);
}
}
......
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2018, Red Hat Inc. All rights reserved.
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2019, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -1666,14 +1666,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
}
// Change state to native (we save the return address in the thread, since it might not
// be pushed on the stack when we do a a stack traversal). It is enough that the pc()
// points into the right code segment. It does not have to be the correct return pc.
// be pushed on the stack when we do a stack traversal).
// We use the same pc/oopMap repeatedly when we call out
intptr_t the_pc = (intptr_t) __ pc();
oop_maps->add_gc_map(the_pc - start, map);
__ set_last_Java_frame(sp, noreg, (address)the_pc, rscratch1);
Label native_return;
__ set_last_Java_frame(sp, noreg, native_return, rscratch1);
Label dtrace_method_entry, dtrace_method_entry_done;
{
......@@ -1804,6 +1801,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
return_type);
}
__ bind(native_return);
intptr_t return_pc = (intptr_t) __ pc();
oop_maps->add_gc_map(return_pc - start, map);
// Unpack native results.
switch (ret_type) {
case T_BOOLEAN: __ c2bool(r0); break;
......
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2019, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -4802,7 +4802,7 @@ class StubGenerator: public StubCodeGenerator {
// Set up last_Java_sp and last_Java_fp
address the_pc = __ pc();
__ set_last_Java_frame(sp, rfp, (address)NULL, rscratch1);
__ set_last_Java_frame(sp, rfp, the_pc, rscratch1);
// Call runtime
if (arg1 != noreg) {
......
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2018, Red Hat Inc. All rights reserved.
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2019, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -1328,9 +1328,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
// pass JNIEnv
__ add(c_rarg0, rthread, in_bytes(JavaThread::jni_environment_offset()));
// It is enough that the pc() points into the right code
// segment. It does not have to be the correct return pc.
__ set_last_Java_frame(esp, rfp, (address)NULL, rscratch1);
// Set the last Java PC in the frame anchor to be the return address from
// the call to the native method: this will allow the debugger to
// generate an accurate stack trace.
Label native_return;
__ set_last_Java_frame(esp, rfp, native_return, rscratch1);
// change thread state
#ifdef ASSERT
......@@ -1351,6 +1353,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
// Call the native method.
__ blr(r10);
__ bind(native_return);
__ maybe_isb();
__ get_method(rmethod);
// result potentially in r0 or v0
......
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, Red Hat Inc.
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Red Hat Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -223,7 +223,13 @@ public class AARCH64CurrentFrameGuess {
}
}
setValues(sp, fp, null);
// We found a PC in the frame anchor. Check that it's plausible, and
// if it is, use it.
if (vm.isJavaPCDbg(pc)) {
setValues(sp, fp, pc);
} else {
setValues(sp, fp, null);
}
return true;
}
......
/*
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, Red Hat Inc.
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Red Hat Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -136,7 +136,15 @@ public class AARCH64Frame extends Frame {
this.raw_sp = raw_sp;
this.raw_unextendedSP = raw_sp;
this.raw_fp = raw_fp;
this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
// We cannot assume SP[-1] always contains a valid return PC (e.g. if
// the callee is a C/C++ compiled frame). If the PC is not known to
// Java then this.pc is null.
Address savedPC = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
if (VM.getVM().isJavaPCDbg(savedPC)) {
this.pc = savedPC;
}
adjustUnextendedSP();
// Frame must be fully constructed before this call
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册