-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
7
-
x86
-
linux
FULL PRODUCT VERSION :
root@w1-em4j005:/opt/vmware# /usr/lib/jvm/java-7-sun/bin/java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux version 2.6.32-24-server (buildd@yellow) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #39-Ubuntu SMP Wed Jul 28 06:21:40 UTC 2010
This bug is reproducible on multiple Linux versions
A DESCRIPTION OF THE PROBLEM :
sun.management.GcInfoBuilder.getLastGcInfo0 occasionally tries to build a new MemoryUsage object in which the Used memory is slightly larger than the Committed memory. This correctly results in an IllegalArgumentException (as per the spec).
The bug only occurs with the G1 GC algorithm.
Not every call to getLastGcInfo will throw the exception, but the attached testcase can reproduce it consistently.
REGRESSION. Last worked in version 7
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached testcase as follows:
/usr/lib/jvm/java-7-sun/bin/java -XX:+UseG1GC JmxExceptionTest
Within 20 seconds or so, it should exit having thrown the exception.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Exception should not be thrown.
ACTUAL -
Exception is sometimes thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at JmxExceptionTest.getLastGcInfoForBeans(JmxExceptionTest.java:38)
at JmxExceptionTest.runTest(JmxExceptionTest.java:61)
at JmxExceptionTest.main(JmxExceptionTest.java:72)
Caused by: java.lang.IllegalArgumentException: used = 10981776 should be <= committed = 10485760
at java.lang.management.MemoryUsage.<init>(MemoryUsage.java:158)
at sun.management.GcInfoBuilder.getLastGcInfo0(Native Method)
at sun.management.GcInfoBuilder.getLastGcInfo(GcInfoBuilder.java:81)
at sun.management.GarbageCollectorImpl.getLastGcInfo(GarbageCollectorImpl.java:97)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:192)
at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:174)
at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:117)
at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:54)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:235)
at com.sun.jmx.mbeanserver.PerInterface.getAttribute(PerInterface.java:83)
at com.sun.jmx.mbeanserver.MBeanSupport.getAttribute(MBeanSupport.java:204)
at javax.management.StandardMBean.getAttribute(StandardMBean.java:372)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:647)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:668)
at com.sun.jmx.mbeanserver.MXBeanProxy$GetHandler.invoke(MXBeanProxy.java:122)
at com.sun.jmx.mbeanserver.MXBeanProxy.invoke(MXBeanProxy.java:167)
at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:265)
at $Proxy0.getLastGcInfo(Unknown Source)
... 7 more
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.ref.SoftReference;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.management.MBeanServer;
import javax.management.ObjectName;
public class JmxExceptionTest {
List<GarbageCollectorMXBean> mBeans = new ArrayList<GarbageCollectorMXBean>();
public JmxExceptionTest() {
try {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
Class gcBeanClass = Class.forName("com.sun.management.GarbageCollectorMXBean");
ObjectName gcBeanObjName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
for (ObjectName name : server.queryNames(gcBeanObjName, null)) {
mBeans.add((GarbageCollectorMXBean)ManagementFactory.newPlatformMXBeanProxy(server, name.getCanonicalName(), gcBeanClass));
}
} catch (Exception e) {
System.err.println("FAILED INIT!");
e.printStackTrace();
}
}
/* Cycle through mBeans invoking getLastGcInfo on each one */
private void getLastGcInfoForBeans() {
for (GarbageCollectorMXBean mBean : mBeans) {
try {
Method getGcInfo = mBean.getClass().getDeclaredMethod("getLastGcInfo");
System.err.println("About to invoke getLastGcInfo on "+mBean.getName());
Object lastGcInfo = getGcInfo.invoke(mBean);
if (lastGcInfo == null) {
System.err.println("NULL lastGcInfo");
}
} catch (InvocationTargetException e) {
e.printStackTrace();
/* If we hit the failure case we expect, this clause should be true */
if (e.getCause() instanceof IllegalArgumentException) {
System.err.println("BINGO!");
}
System.exit(1);
} catch (Exception e) {
e.printStackTrace();
System.err.println("UNEXPECTED EXCEPTION!");
}
}
}
/* Run through filling up the heap at a reasonable rate and checking GC info each time */
private void runTest(int byteArraySizeMb) {
List<SoftReference<byte[]>> srList = new ArrayList<SoftReference<byte[]>>();
while (true) {
srList.add(new SoftReference<byte[]>(new byte[(byteArraySizeMb * 1024 * 1024)]));
getLastGcInfoForBeans();
try {
Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
}
srList.isEmpty();
}
}
public static void main(String args[]) {
new JmxExceptionTest().runTest(10);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The only workaround is to anticipate the exception and swallow it.
root@w1-em4j005:/opt/vmware# /usr/lib/jvm/java-7-sun/bin/java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux version 2.6.32-24-server (buildd@yellow) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #39-Ubuntu SMP Wed Jul 28 06:21:40 UTC 2010
This bug is reproducible on multiple Linux versions
A DESCRIPTION OF THE PROBLEM :
sun.management.GcInfoBuilder.getLastGcInfo0 occasionally tries to build a new MemoryUsage object in which the Used memory is slightly larger than the Committed memory. This correctly results in an IllegalArgumentException (as per the spec).
The bug only occurs with the G1 GC algorithm.
Not every call to getLastGcInfo will throw the exception, but the attached testcase can reproduce it consistently.
REGRESSION. Last worked in version 7
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached testcase as follows:
/usr/lib/jvm/java-7-sun/bin/java -XX:+UseG1GC JmxExceptionTest
Within 20 seconds or so, it should exit having thrown the exception.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Exception should not be thrown.
ACTUAL -
Exception is sometimes thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at JmxExceptionTest.getLastGcInfoForBeans(JmxExceptionTest.java:38)
at JmxExceptionTest.runTest(JmxExceptionTest.java:61)
at JmxExceptionTest.main(JmxExceptionTest.java:72)
Caused by: java.lang.IllegalArgumentException: used = 10981776 should be <= committed = 10485760
at java.lang.management.MemoryUsage.<init>(MemoryUsage.java:158)
at sun.management.GcInfoBuilder.getLastGcInfo0(Native Method)
at sun.management.GcInfoBuilder.getLastGcInfo(GcInfoBuilder.java:81)
at sun.management.GarbageCollectorImpl.getLastGcInfo(GarbageCollectorImpl.java:97)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:192)
at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:174)
at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:117)
at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:54)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:235)
at com.sun.jmx.mbeanserver.PerInterface.getAttribute(PerInterface.java:83)
at com.sun.jmx.mbeanserver.MBeanSupport.getAttribute(MBeanSupport.java:204)
at javax.management.StandardMBean.getAttribute(StandardMBean.java:372)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:647)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:668)
at com.sun.jmx.mbeanserver.MXBeanProxy$GetHandler.invoke(MXBeanProxy.java:122)
at com.sun.jmx.mbeanserver.MXBeanProxy.invoke(MXBeanProxy.java:167)
at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:265)
at $Proxy0.getLastGcInfo(Unknown Source)
... 7 more
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.ref.SoftReference;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.management.MBeanServer;
import javax.management.ObjectName;
public class JmxExceptionTest {
List<GarbageCollectorMXBean> mBeans = new ArrayList<GarbageCollectorMXBean>();
public JmxExceptionTest() {
try {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
Class gcBeanClass = Class.forName("com.sun.management.GarbageCollectorMXBean");
ObjectName gcBeanObjName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
for (ObjectName name : server.queryNames(gcBeanObjName, null)) {
mBeans.add((GarbageCollectorMXBean)ManagementFactory.newPlatformMXBeanProxy(server, name.getCanonicalName(), gcBeanClass));
}
} catch (Exception e) {
System.err.println("FAILED INIT!");
e.printStackTrace();
}
}
/* Cycle through mBeans invoking getLastGcInfo on each one */
private void getLastGcInfoForBeans() {
for (GarbageCollectorMXBean mBean : mBeans) {
try {
Method getGcInfo = mBean.getClass().getDeclaredMethod("getLastGcInfo");
System.err.println("About to invoke getLastGcInfo on "+mBean.getName());
Object lastGcInfo = getGcInfo.invoke(mBean);
if (lastGcInfo == null) {
System.err.println("NULL lastGcInfo");
}
} catch (InvocationTargetException e) {
e.printStackTrace();
/* If we hit the failure case we expect, this clause should be true */
if (e.getCause() instanceof IllegalArgumentException) {
System.err.println("BINGO!");
}
System.exit(1);
} catch (Exception e) {
e.printStackTrace();
System.err.println("UNEXPECTED EXCEPTION!");
}
}
}
/* Run through filling up the heap at a reasonable rate and checking GC info each time */
private void runTest(int byteArraySizeMb) {
List<SoftReference<byte[]>> srList = new ArrayList<SoftReference<byte[]>>();
while (true) {
srList.add(new SoftReference<byte[]>(new byte[(byteArraySizeMb * 1024 * 1024)]));
getLastGcInfoForBeans();
try {
Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
}
srList.isEmpty();
}
}
public static void main(String args[]) {
new JmxExceptionTest().runTest(10);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The only workaround is to anticipate the exception and swallow it.