Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8158837

java/lang/management/MemoryMXBean/Pending.java fails with -limitmods

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 9
    • Fix Version/s: 11
    • Component/s: core-svc
    • Labels:

      Description

      The test jdk/test/java/lang/management/MemoryMXBean/Pending.java is making invalid assumptions about the occurrences of GC, the occurrences of finalization, and the set of objects that might be eligible for finalization.
      The incorrecteness of those assumptions can be seen when the test fails with the -limitmods option as described below.


      The test current fails when supplying the appropriate "-limitmods":
      jtreg ... -javaoptions:"-limitmods jdk.management" java/lang/management/MemoryMXBean/Pending.java
      but passes with no "-limitmods".

      Wrong counts are printed when running failing. With "-limitmods":
         Before creating object: Current finalized = 0 Current pending = 0
         Afer creating objects with no ref: Current finalized = 13 Current pending = 45
         Afer creating objects with ref: Current finalized = 436 Current pending = 97
      Without the "-limitmods"::
         Before creating object: Current finalized = 0 Current pending = 0
         Afer creating objects with no ref: Current finalized = 0 Current pending = 0
         Afer creating objects with ref: Current finalized = 0 Current pending = 0

        Issue Links

          Activity

          Hide
          shurailine Aleksandre Iline added a comment -
          Assigning to Dima for evluation
          Show
          shurailine Aleksandre Iline added a comment - Assigning to Dima for evluation
          Hide
          akulyakh Alexander Kulyakhtin (Inactive) added a comment - - edited
          Test issue. "-limitmods" flag causes a young GC to be provoked. The test doesn't expect it and fails.

          running with an extra "-Xlog:gc" flag prints out information about GC, identifying the issue:

          Failed case: (jtreg -jdk:$JDK9 -javaoptions:"-limitmods jdk.management -Xlog:gc" Pending.java)


          [0.084s][info][gc] Using G1
          [0.340s][info][gc] GC(0) Pause Full (System.gc()) 3M->1M(8M) (0.312s, 0.340s) 28.420ms
          Number of objects pending for finalization:
             Before creating object: Current finalized = 0 Current pending = 0
          [0.487s][info][gc] GC(1) Pause Young (G1 Evacuation Pause) 3M->1M(8M) (0.470s, 0.487s) 16.791ms
             Afer creating objects with no ref: Current finalized = 0 Current pending = 22
             Afer creating objects with ref: Current finalized = 424 Current pending = 107
          ----------System.err:(15/1110)----------
          java.lang.RuntimeException: Unexpected finalized objects: Current finalized = 532 Current pending = 0 but expected = 0
              at Pending.checkFinalizerCount(Pending.java:146)
              at Pending.test(Pending.java:113)
              at Pending.main(Pending.java:71)
              at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-ea/Native Method)
              at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-ea/NativeMethodAccessorImpl.java:62)
              at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:531)
              at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110)
              at java.lang.Thread.run(java.base@9-ea/Thread.java:843)

          Passed case: (jtreg -jdk:$JDK9 -javaoptions:"-Xlog:gc" Pending.java)

          [0.058s][info][gc] Using G1
          [0.410s][info][gc] GC(0) Pause Full (System.gc()) 6M->1M(8M) (0.380s, 0.410s) 29.736ms
          Number of objects pending for finalization:
             Before creating object: Current finalized = 0 Current pending = 0
             Afer creating objects with no ref: Current finalized = 0 Current pending = 0
             Afer creating objects with ref: Current finalized = 0 Current pending = 0
          [0.503s][info][gc] GC(1) Pause Full (System.gc()) 2M->1M(8M) (0.492s, 0.503s) 10.544ms
             After runFinalization 1: Current finalized = 600 Current pending = 0
          Clear all references finalized = Current finalized = 600 Current pending = 0
          [1.672s][info][gc] GC(2) Pause Full (System.gc()) 2M->1M(8M) (1.638s, 1.672s) 33.782ms
             After runFinalization 1: Current finalized = 1100 Current pending = 0
          Show
          akulyakh Alexander Kulyakhtin (Inactive) added a comment - - edited Test issue. "-limitmods" flag causes a young GC to be provoked. The test doesn't expect it and fails. running with an extra "-Xlog:gc" flag prints out information about GC, identifying the issue: Failed case: (jtreg -jdk:$JDK9 -javaoptions:"-limitmods jdk.management -Xlog:gc" Pending.java) [0.084s][info][gc] Using G1 [0.340s][info][gc] GC(0) Pause Full (System.gc()) 3M->1M(8M) (0.312s, 0.340s) 28.420ms Number of objects pending for finalization:    Before creating object: Current finalized = 0 Current pending = 0 [0.487s][info][gc] GC(1) Pause Young (G1 Evacuation Pause) 3M->1M(8M) (0.470s, 0.487s) 16.791ms    Afer creating objects with no ref: Current finalized = 0 Current pending = 22    Afer creating objects with ref: Current finalized = 424 Current pending = 107 ----------System.err:(15/1110)---------- java.lang.RuntimeException: Unexpected finalized objects: Current finalized = 532 Current pending = 0 but expected = 0     at Pending.checkFinalizerCount(Pending.java:146)     at Pending.test(Pending.java:113)     at Pending.main(Pending.java:71)     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0( java.base@9-ea /Native Method)     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke( java.base@9-ea /NativeMethodAccessorImpl.java:62)     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke( java.base@9-ea /DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke( java.base@9-ea /Method.java:531)     at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110)     at java.lang.Thread.run( java.base@9-ea /Thread.java:843) Passed case: (jtreg -jdk:$JDK9 -javaoptions:"-Xlog:gc" Pending.java) [0.058s][info][gc] Using G1 [0.410s][info][gc] GC(0) Pause Full (System.gc()) 6M->1M(8M) (0.380s, 0.410s) 29.736ms Number of objects pending for finalization:    Before creating object: Current finalized = 0 Current pending = 0    Afer creating objects with no ref: Current finalized = 0 Current pending = 0    Afer creating objects with ref: Current finalized = 0 Current pending = 0 [0.503s][info][gc] GC(1) Pause Full (System.gc()) 2M->1M(8M) (0.492s, 0.503s) 10.544ms    After runFinalization 1: Current finalized = 600 Current pending = 0 Clear all references finalized = Current finalized = 600 Current pending = 0 [1.672s][info][gc] GC(2) Pause Full (System.gc()) 2M->1M(8M) (1.638s, 1.672s) 33.782ms    After runFinalization 1: Current finalized = 1100 Current pending = 0
          Hide
          dholmes David Holmes added a comment -
          The test is in general making invalid assumptions about the occurrences of GC, the occurrences of finalization, and the set of objects that might be eligible for finalization.
          Show
          dholmes David Holmes added a comment - The test is in general making invalid assumptions about the occurrences of GC, the occurrences of finalization, and the set of objects that might be eligible for finalization.
          Hide
          dfazunen Dmitry Fazunenko (Inactive) added a comment -
          Perhaps, the following code could be used by the test to check if unexpected GC has happened:

           import java.lang.management.GarbageCollectorMXBean;
          ...
                 List<GarbageCollectorMXBean> gcBeans =
                          ManagementFactory.getGarbageCollectorMXBeans();

                  long gcCount = gcBeans.stream().mapToLong(GarbageCollectorMXBean::getCollectionCount).sum();
          Show
          dfazunen Dmitry Fazunenko (Inactive) added a comment - Perhaps, the following code could be used by the test to check if unexpected GC has happened:  import java.lang.management.GarbageCollectorMXBean; ...        List<GarbageCollectorMXBean> gcBeans =                 ManagementFactory.getGarbageCollectorMXBeans();         long gcCount = gcBeans.stream().mapToLong(GarbageCollectorMXBean::getCollectionCount).sum();
          Hide
          dholmes David Holmes added a comment -
          Perhaps - but the test is still assuming it is the only source of finalizable objects. Without full control of all executing java code you can't reliably test for changes in the pending value in any detail.
          Show
          dholmes David Holmes added a comment - Perhaps - but the test is still assuming it is the only source of finalizable objects. Without full control of all executing java code you can't reliably test for changes in the pending value in any detail.
          Hide
          dcubed Daniel Daugherty added a comment -
          This test failure mode was spotted 2 weeks ago.
          Why hasn't this test been quarantined yet?
          Show
          dcubed Daniel Daugherty added a comment - This test failure mode was spotted 2 weeks ago. Why hasn't this test been quarantined yet?
          Hide
          akulyakh Alexander Kulyakhtin (Inactive) added a comment -
          Need to change the test so that it allows for other causes of gc except that of the test itself.
          Show
          akulyakh Alexander Kulyakhtin (Inactive) added a comment - Need to change the test so that it allows for other causes of gc except that of the test itself.
          Hide
          lmesnik Leonid Mesnik added a comment -
          RULE "java/lang/management/MemoryMXBean/PendingAllGC.sh" Exception java.lang.RuntimeException: Unexpected finalized objects: Current finalized = ... Current pending = ... but expected = ...
          Show
          lmesnik Leonid Mesnik added a comment - RULE "java/lang/management/MemoryMXBean/PendingAllGC.sh" Exception java.lang.RuntimeException: Unexpected finalized objects: Current finalized = ... Current pending = ... but expected = ...

            People

            • Assignee:
              hb Harsha Wardhana B
              Reporter:
              shurailine Aleksandre Iline
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated: