8209413: AArch64: NPE in clhsdb jstack command
Reviewed-by: aph
This commit is contained in:
parent
211162fd5c
commit
4e09929ef9
src
hotspot/cpu/aarch64
macroAssembler_aarch64.cppsharedRuntime_aarch64.cppstubGenerator_aarch64.cpptemplateInterpreterGenerator_aarch64.cpp
jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
@ -373,15 +373,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()));
|
||||
@ -398,7 +392,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
@ -1782,14 +1782,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;
|
||||
{
|
||||
@ -1922,6 +1919,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;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
@ -4800,7 +4800,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) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
@ -1351,9 +1351,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
|
||||
@ -1374,6 +1376,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
|
||||
|
||||
// Call the native method.
|
||||
__ blrt(r10, rscratch1);
|
||||
__ bind(native_return);
|
||||
__ maybe_isb();
|
||||
__ get_method(rmethod);
|
||||
// result potentially in r0 or v0
|
||||
|
12
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java
12
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user