JDK-8158837 : java/lang/management/MemoryMXBean/Pending.java fails with -limitmods
  • Type: Bug
  • Component: core-svc
  • Sub-Component: java.lang.management
  • Affected Version: 9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • Submitted: 2016-06-06
  • Updated: 2023-10-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8159959 :  
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


Comments
RULE "java/lang/management/MemoryMXBean/PendingAllGC.sh" Exception java.lang.RuntimeException: Unexpected finalized objects: Current finalized = ... Current pending = ... but expected = ...
05-07-2016

Need to change the test so that it allows for other causes of gc except that of the test itself.
24-06-2016

This test failure mode was spotted 2 weeks ago. Why hasn't this test been quarantined yet?
20-06-2016

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.
09-06-2016

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.
08-06-2016

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();
08-06-2016

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
07-06-2016

Assigning to Dima for evluation
07-06-2016