JDK-6513211 : Variable value corruption with JIT compilation
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-01-15
  • Updated: 2011-02-16
  • Resolved: 2007-01-16
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)


FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Dell Inspiron 5150, Pentium 4, 2.66GHz, 512MB RAM

A DESCRIPTION OF THE PROBLEM :
Variable value unexpectedly changes.

THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: No

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just compile and run the example program.  We could always reproduce the bug with both command line and Eclipse.  On Linux 2.6.17, however, we could not reproduce the bug with the same JDK version (1.6.0-b105).


EXPECTED VERSUS ACTUAL BEHAVIOR :
The program should always print "true, true" 5 times, but with client VM it prints "true, false" after 3 or 4 iteratioins.  With -XX:CompileThreshold=1, the empty loop is not necessary and the bug always appear in the second iteration.
REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

public class BuggyAction {
  protected static void doSomething() {
    boolean brk = true, pre = false;  // order matters.
    for (int j = 0; j < 1; j++) {
    	pre = brk;
        brk = false;
        System.out.print(pre + ",");
    }
    System.out.println(pre);
    for(int i = 0; i < 1000; ++i);  // not needed with -XX:CompleThreshold=1
  }
  public static void main(String[] args) {
   for(int i = 0; i < 5; i++){
      doSomething();
      System.out.println("----------------------");
    }
  }
}
---------- END SOURCE ----------