JDK-8027230 : Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
  • Type: Bug
  • Component: core-svc
  • Sub-Component: java.lang.instrument
  • Affected Version: 7u25,emb-8u6,emb-8u26,8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • Submitted: 2013-08-19
  • Updated: 2014-07-29
  • Resolved: 2014-05-26
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.
JDK 8 JDK 9
8u20 b17Fixed 9Fixed
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_25 " 
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 7 64-bit

A DESCRIPTION OF THE PROBLEM :
Overflow in method long getObjectSize(Object objectToSize) from java.lang.instrument.Instrumentation

instrumentation.getObjectSize(new int[600_000_000]) returns -1894967280 (negative value)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java.exe -Xmx4000m -javaagent:object_size_test.jar -jar object_size_test.jar

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2400000016
ACTUAL -
-1894967280

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.lang.instrument.Instrumentation;

public class ObjectSizeTest {

private static Instrumentation instrumentation;

public static void premain(String options, Instrumentation instrumentation) {
ObjectSizeTest.instrumentation = instrumentation;
}

public static void main(String[] args) {
int[] a = new int[1000_000_000];
System.out.println(instrumentation.getObjectSize(a));
}
}
---------- END SOURCE ----------
Comments
Release team: Approved for deferral. Putting on 8-pool.
21-11-2013

ILW=MHM=P3, Medium impact as incorrect data, happens always on all platforms, workaround is to determine array size by hand (i.e. elementsize*length+fuzz).
15-11-2013

8-defer-request-justification: This is a non-critical P3 feature which we should look at for an 8 update.
15-11-2013