8209585: [Graal] vmTestbase/nsk/jvmti/scenarios/sampling tests fail with "Too small stack of resumed thread"
authordtitov
Fri, 31 Aug 2018 11:56:43 -0700
changeset 51613 3835dc32de5e
parent 51612 bdac20c6c8dd
child 51614 36773a4fe3e7
8209585: [Graal] vmTestbase/nsk/jvmti/scenarios/sampling tests fail with "Too small stack of resumed thread" Reviewed-by: sspitsyn, amenkov, cjplummer, jcbeyler
test/hotspot/jtreg/ProblemList-graal.txt
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/TestDescription.java
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/TestDescription.java
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/TestDescription.java
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/TestDescription.java
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp
--- a/test/hotspot/jtreg/ProblemList-graal.txt	Fri Aug 31 18:01:47 2018 +0100
+++ b/test/hotspot/jtreg/ProblemList-graal.txt	Fri Aug 31 11:56:43 2018 -0700
@@ -147,11 +147,6 @@
 
 vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/TestDescription.java         8051349   generic-all
 
-vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/TestDescription.java         8209585   generic-all
-vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/TestDescription.java         8209585   generic-all
-vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/TestDescription.java         8209585   generic-all
-vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/TestDescription.java         8209585   generic-all
-
 runtime/appcds/cacheObject/ArchivedModuleCompareTest.java                          8209534   generic-all
 runtime/appcds/cacheObject/ArchivedModuleComboTest.java                            8209534   generic-all
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/TestDescription.java	Fri Aug 31 18:01:47 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/TestDescription.java	Fri Aug 31 11:56:43 2018 -0700
@@ -32,13 +32,12 @@
  *     This JVMTI test is for SP02 scenario of "time sampling profiling" area.
  *     This test checks that JVMTI methods GetFrameCount() and GetStackTrace()
  *     return expected number of stack frames for each kind of thread.
- *     Threads are supended/resumed individually by SuspendThread() and ResumeThread().
- *     Checked statements:
+ *     Threads are suspended/resumed individually by SuspendThread() and ResumeThread().
+ *     Checked statements for suspended threads:
  *         - number of stack frames returned by GetFramesCount() and GetStackTrace()
- *           are not less than expected minimal stack depth.
+ *           are not less than expected minimal stack depth
  *         - number of stack frames returned by GetFrameCount() should be equal to
- *           or less than frames number returned by successive call to GetStackTrace()
- *         - for suspended thread these numbers should be strictly equal
+ *           frames number returned by successive call to GetStackTrace()
  *     Tested threads:
  *         Running             - running in Java method
  *         Entering            - entering monitor in synchronized block
@@ -48,11 +47,10 @@
  *         RunningNative       - running in native method
  *     Testcases:
  *         - start threads
- *         - check stack frames of not suspended threads
  *         - suspend each threads
  *         - check stack frames of suspended threads
  *         - resume each threads
- *         - check stack frames of resumed threads
+
  * COMMENTS
  *     Fixed according to test bug:
  *     6405644 TEST_BUG: no proper sync with agent thread in sp02t001/sp02t003
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp	Fri Aug 31 18:01:47 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp	Fri Aug 31 11:56:43 2018 -0700
@@ -64,7 +64,7 @@
 
 /* testcase(s) */
 static int prepare();
-static int checkThreads(int suspended, const char* kind);
+static int checkSuspendedThreads();
 static int suspendThreadsIndividually(int suspend);
 static int clean();
 
@@ -87,20 +87,14 @@
             nsk_jvmti_setFailStatus();
             return;
         }
-
-        /* testcase #1: check not suspended threads */
-        NSK_DISPLAY0("Testcase #1: check stack frames of not suspended threads\n");
-        if (!checkThreads(NSK_FALSE, "not suspended"))
-            return;
-
         /* suspend threads */
         NSK_DISPLAY0("Suspend each thread\n");
         if (!suspendThreadsIndividually(NSK_TRUE))
             return;
 
-        /* testcase #2: check suspended threads */
-        NSK_DISPLAY0("Testcase #2: check stack frames of suspended threads\n");
-        if (!checkThreads(NSK_TRUE, "suspended"))
+        /* check suspended threads */
+        NSK_DISPLAY0("Check stack frames of suspended threads\n");
+        if (!checkSuspendedThreads())
             return;
 
         /* resume threads */
@@ -108,11 +102,6 @@
         if (!suspendThreadsIndividually(NSK_FALSE))
             return;
 
-        /* testcase #3: check resumed threads */
-        NSK_DISPLAY0("Testcase #3: check stack frames of resumed threads\n");
-        if (!checkThreads(NSK_FALSE, "resumed"))
-            return;
-
         /* clean date: delete threads references */
         NSK_DISPLAY0("Clean data\n");
         if (!clean()) {
@@ -237,12 +226,11 @@
  *    - invoke getFrameCount() for each thread
  *    - check if frameCount is not less than minimal stack depth
  *    - invoke getStackTrace() for each thread
- *    - check if stack depth is not less than frameCount
- *    - for suspended thread check if stack depth is equal to frameCount
+ *    - check if stack depth is equal to frameCount
  *
  * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
  */
-static int checkThreads(int suspended, const char* kind) {
+static int checkSuspendedThreads() {
     int i;
 
     /* check each thread */
@@ -276,35 +264,23 @@
 
         /* check frame count */
         if (frameCount < threadsDesc[i].minDepth) {
-            NSK_COMPLAIN5("Too few frameCount of %s thread #%d (%s):\n"
+            NSK_COMPLAIN4("Too few frameCount of suspended thread #%d (%s):\n"
                             "#   got frameCount:   %d\n"
                             "#   expected minimum: %d\n",
-                            kind, i, threadsDesc[i].threadName,
+                            i, threadsDesc[i].threadName,
                             (int)frameCount, threadsDesc[i].minDepth);
             nsk_jvmti_setFailStatus();
         }
 
-        /* check if stack size is not less than frameCount */
-        if (frameStackSize < frameCount) {
-            NSK_COMPLAIN5("Too small stack of %s thread #%d (%s):\n"
+        if (frameStackSize != frameCount) {
+            NSK_COMPLAIN4("Different frames count for suspended thread #%d (%s):\n"
                             "#   getStackTrace(): %d\n"
                             "#   getFrameCount(): %d\n",
-                            kind, i, threadsDesc[i].threadName,
+                            i, threadsDesc[i].threadName,
                             (int)frameStackSize, (int)frameCount);
             nsk_jvmti_setFailStatus();
         }
 
-        /* for suspended thread: check if stack size is equal to frameCount */
-        if (suspended) {
-            if (frameStackSize != frameCount) {
-                NSK_COMPLAIN5("Different frames count for %s thread #%d (%s):\n"
-                                "#   getStackTrace(): %d\n"
-                                "#   getFrameCount(): %d\n",
-                                kind, i, threadsDesc[i].threadName,
-                                (int)frameStackSize, (int)frameCount);
-                nsk_jvmti_setFailStatus();
-            }
-        }
     }
 
     /* test may continue */
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/TestDescription.java	Fri Aug 31 18:01:47 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/TestDescription.java	Fri Aug 31 11:56:43 2018 -0700
@@ -32,10 +32,10 @@
  *     This JVMTI test is for SP02 scenario of "time sampling profiling" area.
  *     This test checks that JVMTI methods GetStackTrace() returns expected list
  *     of stack frames including frame for tested method.
- *     Threads are supended/resumed individually by SuspendThread() and ResumeThread().
+ *     Threads are suspended/resumed individually by SuspendThread() and ResumeThread().
  *     Checked statements:
- *         - number of stack frames returned by GetFramesCount() should be equal or
- *           less than number returned by successive call to GetStackTrace()
+ *         - for suspended threads number of stack frames returned by GetFrameCount()
+  *          should be equal to frames number returned by successive call to GetStackTrace()
  *         - list of stack frames returned by GetStackTrace() should include
  *           frame for tested method
  *     Tested threads:
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp	Fri Aug 31 18:01:47 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp	Fri Aug 31 11:56:43 2018 -0700
@@ -268,8 +268,8 @@
 /**
  * Testcase: check tested threads
  *    - call GetFrameCount() and getStackTrace()
- *    - compare numbers of stack frame returned
- *    - find stck frane with expected methodID
+ *    - for suspended thread compare number of stack frames returned
+ *    - find stack frames with expected methodID
  *
  * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
  */
@@ -306,13 +306,14 @@
 
         NSK_DISPLAY1("    stack depth: %d\n", (int)frameStackSize);
 
-        /* check stack size */
-        if (frameStackSize < frameCount) {
-            NSK_COMPLAIN5("Too small stack of %s thread #%d (%s):\n"
-                            "#   got ctack frames:  %d\n"
-                            "#   got framesCount:   %d\n",
-                            kind, i, threadsDesc[i].threadName,
-                            (int)frameStackSize, (int)frameCount);
+        /*  Only check for suspended threads: running threads might have different
+            frames between stack grabbing calls. */
+        if (suspended && (frameStackSize != frameCount)) {
+            NSK_COMPLAIN5("Different frames count for %s thread #%d (%s):\n"
+                          "#   getStackTrace(): %d\n"
+                          "#   getFrameCount(): %d\n",
+                          kind, i, threadsDesc[i].threadName,
+                          (int)frameStackSize, (int)frameCount);
             nsk_jvmti_setFailStatus();
         }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/TestDescription.java	Fri Aug 31 18:01:47 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/TestDescription.java	Fri Aug 31 11:56:43 2018 -0700
@@ -32,20 +32,15 @@
  *     This JVMTI test is for SP06 scenario of "time sampling profiling" area.
  *     This test checks that JVMTI methods GetStackTrace() returns expected list
  *     of stack frames including frame for tested method even for compiled methods.
- *     The test provokes compilation of tested methods by intensivelly calling
- *     them in a loop and then invokes GenarateEvents() to receive all
+ *     The test provokes compilation of tested methods by intensively calling
+ *     them in a loop and then invokes GenerateEvents() to receive all
  *     COMPILED_METHOD_LOAD events and mark compiled methods.
- *     Threads are supended/resumed individually by SuspendThread() and ResumeThread().
- *     Checked statements:
- *         - number of stack frames returned by GetFramesCount() should be equal or
- *           less than number returned by successive call to GetStackTrace()
- *         - list of stack frames returned by GetStackTrace() should include
- *           frame for tested method
- *     Checked statements:
- *         - stack frame info returned by GetFrameLocation() equals to the
- *           corresponding frame info returmned by GetStackTrace()
- *         - both GetFrameLocation() and GetStackTrace() include frame info
- *           for expected tested method
+ *     Threads are suspended/resumed individually by SuspendThread() and ResumeThread().
+ *     Checked statements for suspended threads:
+ *         - number of stack frames returned by GetFramesCount() and GetStackTrace()
+ *           are not less than expected minimal stack depth
+ *         - for suspended threads the number of stack frames returned by GetFrameCount()
+ *           should be equal to frames number returned by successive call to GetStackTrace()
  *     Tested threads:
  *         Running             - running in Java method
  *         Entering            - entering monitor in synchronized block
@@ -57,11 +52,9 @@
  *         - run threads and provoke methods compilation
  *         - enable events
  *         - call GenerateEvents() and mark compiled methods
- *         - check stack frames of not suspended threads
  *         - suspend each threads
  *         - check stack frames of suspended threads
  *         - resume each threads
- *         - check stack frames of resumed threads
  * COMMENTS
  *     This test is similar to 'sp02t002' but for compiled methods.
  *     Test fixed due to test bug:
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp	Fri Aug 31 18:01:47 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp	Fri Aug 31 11:56:43 2018 -0700
@@ -81,7 +81,7 @@
 /* testcase(s) */
 static int prepare();
 static int generateEvents();
-static int checkThreads(int suspended, const char* kind);
+static int checkSuspendedThreads();
 static int suspendThreadsIndividually(int suspend);
 static int clean();
 
@@ -107,26 +107,18 @@
         if (!generateEvents())
             return;
 
-        NSK_DISPLAY0("Testcase #1: check stack frames of not suspended threads\n");
-        if (!checkThreads(NSK_FALSE, "not suspended"))
-            return;
-
         NSK_DISPLAY0("Suspend each thread\n");
         if (!suspendThreadsIndividually(NSK_TRUE))
             return;
 
-        NSK_DISPLAY0("Testcase #2: check stack frames of suspended threads\n");
-        if (!checkThreads(NSK_TRUE, "suspended"))
+        NSK_DISPLAY0("Check stack frames of suspended threads\n");
+        if (!checkSuspendedThreads())
             return;
 
         NSK_DISPLAY0("Resume each thread\n");
         if (!suspendThreadsIndividually(NSK_FALSE))
             return;
 
-        NSK_DISPLAY0("Testcase #3: check stack frames of resumed threads\n");
-        if (!checkThreads(NSK_FALSE, "resumed"))
-            return;
-
         NSK_DISPLAY0("Clean data\n");
         if (!clean()) {
             nsk_jvmti_setFailStatus();
@@ -290,12 +282,11 @@
  *    - invoke getFrameCount() for each thread
  *    - check if frameCount is not less than minimal stack depth
  *    - invoke getStackTrace() for each thread
- *    - check if stack depth is not less than frameCount
- *    - for suspended thread check if stack depth is equal to frameCount
+ *    - check if stack depth is equal to frameCount
  *
  * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
  */
-static int checkThreads(int suspended, const char* kind0) {
+static int checkSuspendedThreads() {
     char kind[256] = "";
     int i;
 
@@ -308,7 +299,6 @@
 
         /* make proper kind */
         strcpy(kind, threadsDesc[i].methodCompiled ? "compiled " : "not compiled ");
-        strcat(kind, kind0);
         NSK_DISPLAY2("  thread #%d (%s):\n", i, threadsDesc[i].threadName);
 
         /* get frame count */
@@ -341,9 +331,8 @@
             nsk_jvmti_setFailStatus();
         }
 
-        /* check if stack size is not less than frameCount */
-        if (frameStackSize < frameCount) {
-            NSK_COMPLAIN5("Too small stack of %s thread #%d (%s):\n"
+        if (frameStackSize != frameCount) {
+            NSK_COMPLAIN5("Different frames count for %s thread #%d (%s):\n"
                             "#   getStackTrace(): %d\n"
                             "#   getFrameCount(): %d\n",
                             kind, i, threadsDesc[i].threadName,
@@ -351,17 +340,6 @@
             nsk_jvmti_setFailStatus();
         }
 
-        /* for suspended thread: check if stack size is equal to frameCount */
-        if (suspended) {
-            if (frameStackSize != frameCount) {
-                NSK_COMPLAIN5("Different frames count for %s thread #%d (%s):\n"
-                                "#   getStackTrace(): %d\n"
-                                "#   getFrameCount(): %d\n",
-                                kind, i, threadsDesc[i].threadName,
-                                (int)frameStackSize, (int)frameCount);
-                nsk_jvmti_setFailStatus();
-            }
-        }
     }
 
     /* test may continue */
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/TestDescription.java	Fri Aug 31 18:01:47 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/TestDescription.java	Fri Aug 31 11:56:43 2018 -0700
@@ -32,20 +32,15 @@
  *     This JVMTI test is for SP06 scenario of "time sampling profiling" area.
  *     This test checks that JVMTI methods GetStackTrace() returns expected list
  *     of stack frames including frame for tested method even for compiled methods.
- *     The test provokes compilation of tested methods by intensivelly calling
- *     them in a loop and then invokes GenarateEvents() to receive all
+ *     The test provokes compilation of tested methods by intensively calling
+ *     them in a loop and then invokes GenerateEvents() to receive all
  *     COMPILED_METHOD_LOAD events and mark compiled methods.
- *     Threads are supended/resumed individually by SuspendThread() and ResumeThread().
+ *     Threads are suspended/resumed individually by SuspendThread() and ResumeThread().
  *     Checked statements:
- *         - number of stack frames returned by GetFramesCount() should be equal or
- *           less than number returned by successive call to GetStackTrace()
+ *         - for suspended threads number of stack frames returned by GetFrameCount()
+ *           should be equal to frames number returned by successive call to GetStackTrace()
  *         - list of stack frames returned by GetStackTrace() should include
  *           frame for tested method
- *     Checked statements:
- *         - stack frame info returned by GetFrameLocation() equals to the
- *           corresponding frame info returmned by GetStackTrace()
- *         - both GetFrameLocation() and GetStackTrace() include frame info
- *           for expected tested method
  *     Tested threads:
  *         Running             - running in Java method
  *         Entering            - entering monitor in synchronized block
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp	Fri Aug 31 18:01:47 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp	Fri Aug 31 11:56:43 2018 -0700
@@ -289,8 +289,8 @@
 /**
  * Testcase: check tested threads.
  *    - call GetFrameCount() and getStackTrace()
- *    - compare numbers of stack frame returned
- *    - find stck frane with expected methodID
+ *    - for suspended thread compare number of stack frames returned
+ *    - find stack frames with expected methodID
  *
  * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
  */
@@ -331,13 +331,14 @@
 
         NSK_DISPLAY1("    stack depth: %d\n", (int)frameStackSize);
 
-        /* check stack size */
-        if (frameStackSize < frameCount) {
-            NSK_COMPLAIN5("Too small stack of %s thread #%d (%s):\n"
-                            "#   got ctack frames:  %d\n"
-                            "#   got framesCount:   %d\n",
-                            kind, i, threadsDesc[i].threadName,
-                            (int)frameStackSize, (int)frameCount);
+        /*  Only check for suspended threads: running threads might have different
+            frames between stack grabbing calls. */
+        if (suspended && (frameStackSize != frameCount)) {
+            NSK_COMPLAIN5("Different frames count for %s thread #%d (%s):\n"
+                          "#   getStackTrace(): %d\n"
+                          "#   getFrameCount(): %d\n",
+                          kind, i, threadsDesc[i].threadName,
+                          (int)frameStackSize, (int)frameCount);
             nsk_jvmti_setFailStatus();
         }