United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6512534 : Strange behavior of Client VM (Unexpected value change on the specific situation)

Details
Type:
Bug
Submit Date:
2007-01-12
Status:
Resolved
Updated Date:
2010-12-03
Project Name:
JDK
Resolved Date:
2007-02-17
Component:
hotspot
OS:
windows_xp
Sub-Component:
compiler
CPU:
x86,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
hs10 (b08)

Related Reports
Backport:
Backport:
Duplicate:
Duplicate:
Duplicate:

Sub Tasks

Description
Please run the attached test programs(Test1.java) using Client VM or take a look at
the attached test result(result.txt). You'll notice that a variable(pre)'s value
is unexpectedly changed from true to false (at line 34 in result.txt) in the middle
of execution.
Based on circumstantial evidence, we think there is a bug in client VM.

Additional info:
  - This bug is reproducible only with Client VM. Not reproducible with -server nor -Xint.
  - This bug is not always reproducible. Please run the test program several times if you
    don't see the symptom.
  - Interestingly, this bug becomes non-reproducible
      * if you comment out the assignment expression to a variable(brk) at line 17
        or the "for" loop at line 27
      - or -
      * if you rearrange the order of two variable definitions at line 4 and 5.
            boolean brk = true;
            boolean pre = false;
According to the original bug reporter, this can be reproducible with a break statement with a label as well as a continue statement.

                                    

Comments
SUGGESTED FIX

http://prt-web.sfbay.sun.com/net/prt-archiver.sfbay/data/archived_workspaces/main/c2_baseline/2007/20070207172045.never.6512534/workspace/webrevs/webrev-2007.02.08/index.html
                                     
2007-02-08
SUGGESTED FIX

*** /tmp/geta22905      Tue Jan 16 13:53:53 2007
--- c1_LIRGenerator.cpp Tue Jan 16 13:53:51 2007
***************
*** 136,144 ****
      assert(node == NULL || node->operand() == opr, "");
      if (node == NULL) {
        node = new ResolveNode(opr);
-       if (source) virtual_operands().append(node);
        vreg_table()[vreg_num] = node;
      }
    } else {
      assert(source, "");
      node = new ResolveNode(opr);
--- 136,148 ----
      assert(node == NULL || node->operand() == opr, "");
      if (node == NULL) {
        node = new ResolveNode(opr);
        vreg_table()[vreg_num] = node;
      }
+     // Make sure that all virtual operands show up in the list when
+     // they are used as the source of a move.
+     if (source && !virtual_operands().contains(node)) {
+       virtual_operands().append(node);
+     }
    } else {
      assert(source, "");
      node = new ResolveNode(opr);
                                     
2007-01-16
EVALUATION

This appears to be a problem with the processing of phis.  I'm still trying to identify what's going wrong.  Here's a simplified test case.

public class Test1 {

    static int dummy;

    private static void error() {
        throw new InternalError("");
    }
    private static void ok() {
        System.out.println("true");
    }

    protected static void doSomething() {
        boolean brk = true;
        boolean pre = false;

        for(int i = 0; i < 2; ++i){
            int j = 0;

            while(j < 1){
                ++j;
                if(i == 0){
                    pre = brk;
                    brk = false;
                    continue;
                }
                if (pre == false) error();
            }
        }

        for (int i = 0; i < 1000; ++i);
    }

    public static void main(String[] args) {
        for(int i = 0; i < 5; i++){
            doSomething();
            // System.out.println((i+1) + " ----------------------");
        }
    }

}
                                     
2007-01-12



Hardware and Software, Engineered to Work Together