RFR 6987597: ManagementFactory.getGarbageCollectorMXBeans() returns empty list with CMS

Mandy Chung mandy.chung at oracle.com
Thu Nov 21 08:51:34 PST 2013

Hi Jaroslav,

On 11/19/2013 6:23 AM, Jaroslav Bachorik wrote:
> Please, review this test fix.
> Issue : https://bugs.openjdk.java.net/browse/JDK-6987597
> Webrev: http://cr.openjdk.java.net/~jbachorik/6987597/webrev.03
> The fix moves the execution of the test routine to the 
> GarbageCollectorMXBean notification handler - at that moment it's 
> certain that GC has already happened and it is safe to assert the data 
> provided by the MBean.

This patch may have a potential issue when GC happens during the process 
of adding the notification handlers such as the number of increments is 
greater than the number of registered handlers.   By the time the main 
thread reaches p.arriveAndAwaitAdvance, the phaser has advanced to the 
next phase with few arrived parties and will wait forever (until the 
next GC happens).   This should rarely happen though.  Note that 
p.arriveAndAwaitAdvance continue to run even if the thread is 
interrupted and what happens if jtreg attempts to time out the test?

Does this issue only happen to CMS with background GC thread?   The 
proposed patch seems a little overkill.   I wonder if the test should 
skip if running in CMS background mode.  Does 
-XX:+ExplicitGCInvokesConcurrent flag will get System.gc() to run in 
foreground mode in CMS (I think that may get the GC to complete before 
System.gc() returns?)


More information about the serviceability-dev mailing list