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.

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.

Thanks,
Nick
________________________________
From: Andrew Haley <[email protected]>
Sent: 06 February 2019 18:00:16
To: Nick Gasson (Arm Technology China); [email protected]
Cc: nd; [email protected]
Subject: Re: [aarch64-port-dev ] RFR: 8209413: AArch64: NPE in clhsdb jstack 
command

On 2/5/19 5:57 PM, Andrew Haley wrote:
> On 2/5/19 5:55 PM, Nick Gasson (Arm Technology China) wrote:
>> The stack trace you sent below is incomplete, it's missing the frame for 
>> Spinner.run (i.e. the AARCH64Frame object corresponding to the native 
>> wrapper frame). Did you try on x86 or with the patch I posted? I'm not able 
>> to test at the moment but I think you will get one exra frame in the output. 
>> I don't know why you don't get the NPE, I guess it depends on what's in that 
>> stack slot.
>
> Never mind, found it. A more complex test is needed.

Here's the test that reveals the problem: it seems that you need an entry frame
which calls compiled Java code.

[aph@merino ~]$ cat Spinner.c
#include <jni.h>
#include <stdio.h>

/*
 * Class:     Spinner
 * Method:    run
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_Spinner_run(JNIEnv *env,  jclass cls) {
  jmethodID mid = (*env)->GetStaticMethodID(env, cls, "test", "()V");
  (*env)->CallStaticVoidMethod(env, cls, mid);
  // printf("Spinning...\n");
  // for(;;);
}


[aph@merino ~]$ cat Spinner.java
public class Spinner {
    static native void run();

    static {
        System.loadLibrary("Spinner");
    }

    static volatile int nn;

    public static void test() {
        System.out.println("Spinning");
        for(int i = 1; i !=0; i = (i + 1) | 1)
            nn = (int)Math.log(i);
    }

    public static void main(String[] args) {
        run();
    }
}

--
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671

Reply via email to