JDK-6763111 : Data corruption in compiler1 when expression throws an Exception
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs14
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2008-10-23
  • Updated: 2010-04-03
  • Resolved: 2008-11-04
Related Reports
Duplicate :  
Description
The following  minimized testcase (also attached) results in different
results when running in -Xcomp and -Xint modes.

=================== Tester.java ==============
class Tester_Class_0
{
    static byte var_0 = 1;
}

class Tester_Class_2
{
    static byte var_2 = ++Tester_Class_0.var_0;
}

abstract class Tester_Class_3
{
    byte var_3 = 0;
}

public class Tester 
{
    long var = Tester_Class_0.var_0;

    Object var_4;

    private void test()
    {
        // Note, this expression throws ClassCastException when trying
        //  to cast var_4 to Tester_Class_3
        
        Tester_Class_0.var_0 += Tester_Class_2.var_2 +  
(((Tester_Class_3)( var_4 = new byte[Tester_Class_0.var_0] )).var_3 += 1);

    }

    public static void main(String[] args)
    {
        try {
            Tester t = new Tester();
            try { t.test(); }
            catch(Throwable e) { }

            System.out.println("Tester.var_4 = " + print_r(t.var_4));

        } catch (Throwable e) { }
    }

...

==============================================

java -client -Xint Tester
Tester.var_4 = [0,0]

java -client -Xcomp Tester
Tester.var_4 = [0]

Probably this is caused by the fact that the expression where var_4 is calculated
throws ClassCastException.

Comments
EVALUATION This because the static field access to Tester_Class_2 causes initialization which causes the value of Tester_Class_0.var_0 to change. Value numbering allows commoning of values across this so we don't pick up the new value. This is a day one bug in C1 but it's unlikely to really matter in practice. It's also just the local version of 6756768 so I'm closing this a dup of it.
04-11-2008