[aarch64-port-dev ] RFR: 8209413: AArch64: NPE in clhsdb jstack command
Andrew Haley
aph at redhat.com
Wed Feb 6 18:42:29 UTC 2019
On 2/6/19 10:54 AM, Nick Gasson (Arm Technology China) wrote:
> Hi Andrew
>
>> Here's the test that reveals the problem: it seems that you need an entry frame which calls compiled Java code.
>
> This seems slightly different to the original problem, although
> maybe related. Because here the top-most frame is a compiled Java
> frame we'll take the vm.isJavaPCDbg and !vm.isClientCompiler
> branches of AARCH64CurrentFrameGuess::run which as far as I can tell
> always gets the PC from the thread context. The original crash I was
> looking at happened when the top frame was native (else branch on
> line 183) where the PC is set to null which causes the two-argument
> AARCH64Frame constructor to be used.
OK.
> Unfortunately I'm on holiday until next Thursday so can't test
> anything. Did you try Thread.sleep? That's what LingeredApp that the
> jtreg tests is trying to get a stack trace of calls.
Well, that was fun. When generally assume that we can find a saved PC
in a fixed place in the frame, and this is always the word above the
FP. However, when we're in JNI native code, as you've noticed the
C[++] compiler isn't helpful enough to lave the caller PC in a
well-known place. When the frame is created by our AArch64 assembly-
langage code we'll be fine because we always do the right thing.
The problem is that when we save the Java frame state in the Thread,
we're doing it for the sake of the runtime, not for debuggers, so we
don't always save all the information that a debugger might need.
This patch should work for compiled native methods, but I'm not at all
sure about all of the other places where we call out from runtime
stubs to the VM. We perhaps check that the PC returned by
raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize()) is in the code
cache before we use it.
Anyway, try this: it should fix your immediate bug.
diff -r 3954d70e1c50 src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
--- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Wed Feb 06 08:31:27 2019 +0100
+++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Wed Feb 06 18:22:09 2019 +0000
@@ -1916,10 +1916,20 @@
default:
ShouldNotReachHere();
}
+
+ // Leave a breadcrumb for
+ // sun.jvm.hotspot.runtime.aarch64.AARCH64Frame(sp, fp)
+ Label retaddr;
+ __ adr(rscratch2, retaddr);
+ __ stp(zr, rscratch2, Address(__ pre(sp, -2 * wordSize)));
+
rt_call(masm, native_func,
int_args + 2, // AArch64 passes up to 8 args in int registers
float_args, // and up to 8 float args
return_type);
+
+ __ bind(retaddr);
+ __ add(sp, sp, 2 * wordSize);
}
// Unpack native results.
--
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the serviceability-dev
mailing list