-
Bug
-
Resolution: Fixed
-
P3
-
1.4.1
-
rc
-
x86
-
windows_xp
Name: rmT116609 Date: 07/11/2002
FULL PRODUCT VERSION :
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600], Windows 2000
ADDITIONAL OPERATING SYSTEMS :
Linux (RedHat 7.3) (#1 Thu Apr 18 07:31:07 EDT 2002)
A DESCRIPTION OF THE PROBLEM :
On HotSpot 1.4.1beta with AMD processors, a math error occurs when multipling and adding longs in a certain order.
It will provide the correct results for a while, but will later begin to give incorrect results. I assume this is an HotSpot optimization that doesn't work correctly.
REGRESSION. Last worked in version 1.4
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the source code below on an AMD machine (tested on Athlon, K6-2)
EXPECTED VERSUS ACTUAL BEHAVIOR :
When running the example source code:
Expected: Should print this continuously:
should be 0: 0
Actual: It prints the above for a few seconds, then prints this:
should be 0: 8589934592
The problem is not reproducible if -Xint is used.
The problem is also reproducible on Windows 2000(Service Pack 2, pentium III processor) using JDK1.4.1-beta.
---------- BEGIN SOURCE ----------
public class MathTest {
public static void main(String[] args) {
MathTest test = new MathTest();
while (true) {
// y must be negative, x can be anything
long x = -Math.round(Math.random() * 65535L);
long y = x;
test.compute(x, y);
}
}
long a = 1;
long b = -1;
public void compute(long x, long y) {
// if the next line is commented out, the problem does not occur
long answer1 = a * x - b * y;
long answer2 = a * y + b * x;
System.out.println("should be 0: " + answer2);
}
}
---------- END SOURCE ----------
Release Regression From : 1.4.0_01
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 159216)
======================================================================