-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
8
-
x86_64
-
windows
FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
FULL OS VERSION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Running the attached code with the -XX:+UseG1GC flag causes a double that is in scope and declared as final to be changed from a value of 20 to a value of 0. It is cleared during a loop that is writing to an array of enums.
THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No
THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the attached source and run it with the -XX:+UseG1GC flag
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected Result: "Incrementing Cell Size 21.0" is printed to the console.
Actual Result: "Now it's broken. Iteration: ######" is repeatedly printed to the console after the variable values changes to 0 in the loop.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/**
* @author bkirst
*
*/
public class BugTest
{
public enum EnumUTMHemisphere
{
N, S;
public String value()
{
return name();
}
public static EnumUTMHemisphere fromValue(String v)
{
return valueOf(v);
}
}
/**
* @param args
*/
public static void main(String[] args)
{
fillArray(20);
}
public static void fillArray(double cellSize)
{
final double cellSize_m = cellSize;
EnumUTMHemisphere hemisphere = EnumUTMHemisphere.N;
EnumUTMHemisphere[] hemispheres = new EnumUTMHemisphere[565504];
for (int i = 0; i < 565504; i++)
{
hemispheres[i] = hemisphere;
if (cellSize_m == 0)
{
System.out.println("Now it's broken. Iteration: " + i + " " + cellSize_m);
}
}
System.out.println("Incrementing Cell Size " + (cellSize_m + 1));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't use the G1 Garbage Collector, or use the -Xint flag
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
FULL OS VERSION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Running the attached code with the -XX:+UseG1GC flag causes a double that is in scope and declared as final to be changed from a value of 20 to a value of 0. It is cleared during a loop that is writing to an array of enums.
THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No
THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the attached source and run it with the -XX:+UseG1GC flag
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected Result: "Incrementing Cell Size 21.0" is printed to the console.
Actual Result: "Now it's broken. Iteration: ######" is repeatedly printed to the console after the variable values changes to 0 in the loop.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/**
* @author bkirst
*
*/
public class BugTest
{
public enum EnumUTMHemisphere
{
N, S;
public String value()
{
return name();
}
public static EnumUTMHemisphere fromValue(String v)
{
return valueOf(v);
}
}
/**
* @param args
*/
public static void main(String[] args)
{
fillArray(20);
}
public static void fillArray(double cellSize)
{
final double cellSize_m = cellSize;
EnumUTMHemisphere hemisphere = EnumUTMHemisphere.N;
EnumUTMHemisphere[] hemispheres = new EnumUTMHemisphere[565504];
for (int i = 0; i < 565504; i++)
{
hemispheres[i] = hemisphere;
if (cellSize_m == 0)
{
System.out.println("Now it's broken. Iteration: " + i + " " + cellSize_m);
}
}
System.out.println("Incrementing Cell Size " + (cellSize_m + 1));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't use the G1 Garbage Collector, or use the -Xint flag
- duplicates
-
JDK-8186122 Turning on G1GC inconsistently triggers strange JIT compilation which causes undesired results
-
- Closed
-
-
JDK-8148175 C1: G1 barriers don't preserve FP registers
-
- Closed
-