Native method crashes with garbage collector

Radosław Smogura mail at smogura.eu
Thu Jul 6 15:33:31 UTC 2017


Hi all,

Playing around I’ve found that native method can crash garbage collector if hotspot is compiled with assertions. Below is narrowed test case

public class SleepCrash {
    public static void main(String[] args) throws Throwable {
        MethodHandle sleep = MethodHandles.lookup().findNative("sleep", MethodType.methodType(int.class, int.class));
        new Thread() {
            @Override
            public void run() {
                while (true) {
                    System.out.println(".\n");
                    System.gc();
                }
            }            
        }.start();
        sleep.invoke(12);
    }
}

Attached hs_error.

Best regards,
Radek



More information about the panama-dev mailing list