JDK-6795161 : Escape analysis leads to data corruption
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs14
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2009-01-18
  • Updated: 2010-04-03
  • Resolved: 2009-02-06
Related Reports
Duplicate :  
Description
The following test case results in wrong data (variable var_check)
when running with enabled escape analysis.

 > jdk7b43/bin/java -server -Xcomp -XX:CompileOnly=EATester -XX:+DoEscapeAnalysis EATester
 EATester.var_check = 0 (expected 1)

the results are ok when running with disabled escape analysis:
 > jdk7b43/bin/java -server -Xcomp -XX:CompileOnly=EATester -XX:-DoEscapeAnalysis EATester
 EATester.var_check = 1 (expected 1)

========= EATester.java =========
class EATester_Class_1 {
    static String var_1;

    static void badFunc(int size)
    {
        try {
          for (int i = 0; i < 1; (new byte[size-i])[0] = 0, i++) {}
        } catch (Exception e) {
          // don't comment it out, it will lead to correct results ;)
          //System.out.println("Got exception: " + e);
        }
    }
}

public class EATester {
    static String var_1_copy = EATester_Class_1.var_1;

    static byte var_check;

    public static void main(String[] args)
    {
        var_check = 1;

        EATester_Class_1.badFunc(-1);

        System.out.println("EATester.var_check = " + EATester.var_check + " (expected 1)\n");
    }
}
=================================