Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4971887

Incorrect floating-point arithmetic or loop unrolling with -server -Xcomp option

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 1.4.2, 1.4.2_12, 5.0
    • hotspot
    • b35
    • sparc
    • solaris_8, solaris_9, solaris_nevada, solaris_10

        Name: tb29552 Date: 12/22/2003


        FULL PRODUCT VERSION :
        java version "1.4.2_03"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
        Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)


        FULL OS VERSION :
        SunOS ussunx4 5.8 Generic_108528-10 sun4u sparc SUNW,Sun-Blade-1000

        EXTRA RELEVANT SYSTEM CONFIGURATION :
          Program is actually running as part of the J2EE application on the JBoss 3.2 server.

        A DESCRIPTION OF THE PROBLEM :
        The attached program does not add up integers correctly when using the Hotspot server compiler.

        This bug may be related to 4843257. However, 4843257 was closed int Apr 2003, and this bug still occurs on Solaris.

        I was unable to reproduce the bug on Windows.






        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile attached program: "javac Bug.java"
        Run program: "java -server -Xcomp Bug"

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        total=1118.0

        ACTUAL -
        total=-1.8014390618947024E16

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class Bug
        {
            public static double calcTotal ( long[] counts )
            {
                double total = 0;
                for ( int i=0; i < counts.length; i++ )
                {
                    total += counts[i];
                }
                return ( total );
            }
            
            public static void main ( String[] args )
            {
               long[] counts = new long[] {
                        113,64,23,56,98,48,33,101,8,14,27,58,17,6,
                        121,18,3,3,24,13,58,14,23,14,4,123,29,5 };
               double total = Bug.calcTotal( counts );
               System.out.println( "total=" + total );
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        The program work CORRECTLY if I disable loop unrolling:
           java -server -Xcomp -XX:LoopUnrollLimit=0 Bug

        It also works CORRECTLY if I I disable the Hotspot server compiler:
           java -Xcomp Bug
        Unfortunately this has a negetice effect on overall system performance.
        (Review ID: 231819)
        ======================================================================

              rasbold Chuck Rasbold
              tbell Tim Bell
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: