changeset 48301:32f13c6c1bbd

8192897: NPE occurs on clhsdb jstack Reviewed-by: dholmes, sspitsyn, jgeorge, sballal
author ysuenaga
date Mon, 04 Dec 2017 10:23:08 +0900
parents 8a5edac3d5a2
children 50181ff45d46
files src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java
diffstat 2 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java	Mon Dec 04 23:55:52 2017 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java	Mon Dec 04 10:23:08 2017 +0900
@@ -128,6 +128,9 @@
 
   /** Returns List<MonitorInfo> */
   public List<MonitorInfo> getMonitors() {
+    if (getScope() == null) {
+      return new ArrayList<>();
+    }
     List monitors = getScope().getMonitors();
     if (monitors == null) {
       return new ArrayList<>();
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java	Mon Dec 04 23:55:52 2017 +0100
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java	Mon Dec 04 10:23:08 2017 +0900
@@ -38,14 +38,17 @@
 
 public class ClhsdbJstack {
 
-    public static void main(String[] args) throws Exception {
-        System.out.println("Starting ClhsdbJstack test");
-
+    private static void testJstack(boolean withXcomp) throws Exception {
         LingeredApp theApp = null;
         try {
             ClhsdbLauncher test = new ClhsdbLauncher();
-            theApp = LingeredApp.startApp();
-            System.out.println("Started LingeredApp with pid " + theApp.getPid());
+            theApp = withXcomp ? LingeredApp.startApp(List.of("-Xcomp"))
+                               : LingeredApp.startApp();
+            System.out.print("Started LingeredApp ");
+            if (withXcomp) {
+                System.out.print("(-Xcomp) ");
+            }
+            System.out.println("with pid " + theApp.getPid());
 
             List<String> cmds = List.of("jstack -v");
 
@@ -61,10 +64,16 @@
 
             test.run(theApp.getPid(), cmds, expStrMap, null);
         } catch (Exception ex) {
-            throw new RuntimeException("Test ERROR " + ex, ex);
+            throw new RuntimeException("Test ERROR (with -Xcomp=" + withXcomp + ") " + ex, ex);
         } finally {
             LingeredApp.stopApp(theApp);
         }
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("Starting ClhsdbJstack test");
+        testJstack(false);
+        testJstack(true);
         System.out.println("Test PASSED");
     }
 }