JDK-4526490 : volatile long variable integrity is corrupted on Solx86 on dual-CPU machine
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 2.0,1.4.0,1.4.2,5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,linux,solaris_8,windows_nt
  • CPU: generic,x86
  • Submitted: 2001-11-13
  • Updated: 2008-08-13
  • Resolved: 2003-07-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Name: abR10010			Date: 11/13/2001

Test : nsk/regression/b4459438
TestBase : testbase_nsk

The nsk/regression/b4459438 shows that integrity of static volatile long variable 
is corrupted on Solx86 on dual-CPU machine under the HotSpot VM (build 1.4.0-rc-b85).

This failure happens starting with HotSpot VM build 1.4.0-beta3-b81.

On one-CPU machine the test passes as well as it passes on dual-CPU machine
in -Xcomp mode.

    
See test log:

% .../java/dest/jdk1.4.0beta-b85/solx86/bin/java b4459438
==> nsk/regression/b4459438 test LOG:
--> This test for #4459438 bug; Category: hotspot; Subcategory: hybrid_interpreter
    Synopsis: Accesses to volatile longs don't work in the 64-bit vm

##> Thread number 4: volatile long variable integrity was corrupted:
##>                  full double word = 400000005 (hex)
##>                  left half-word   = 4 (hex)
##>                  right half-word  = 5 (hex)
##>                  But left half-word and right half-word have to be equal!
##>                  Loop iteration number = 19529
##> Thread number 6: volatile long variable integrity was corrupted:
##>                  full double word = 600000005 (hex)
##>                  left half-word   = 6 (hex)
##>                  right half-word  = 5 (hex)
##>                  But left half-word and right half-word have to be equal!
##>                  Loop iteration number = 3171
##> Thread number 8: volatile long variable integrity was corrupted:
##>                  full double word = 800000005 (hex)
##>                  left half-word   = 8 (hex)
##>                  right half-word  = 5 (hex)
##>                  But left half-word and right half-word have to be equal!
##>                  Loop iteration number = 183
##> Thread number 2: volatile long variable integrity was corrupted:
##>                  full double word = 200000005 (hex)
##>                  left half-word   = 2 (hex)
##>                  right half-word  = 5 (hex)
##>                  But left half-word and right half-word have to be equal!
##>                  Loop iteration number = 217
##> Thread number 3: volatile long variable integrity was corrupted:
##>                  full double word = 300000005 (hex)
##>                  left half-word   = 3 (hex)
##>                  right half-word  = 5 (hex)
##>                  But left half-word and right half-word have to be equal!
##>                  Loop iteration number = 33809
##> Thread number 1: volatile long variable integrity was corrupted:
##>                  full double word = 100000005 (hex)
##>                  left half-word   = 1 (hex)
##>                  right half-word  = 5 (hex)
##>                  But left half-word and right half-word have to be equal!
##>                  Loop iteration number = 2937
##> Thread number 5: volatile long variable integrity was corrupted:
##>                  full double word = 500000007 (hex)
##>                  left half-word   = 5 (hex)
##>                  right half-word  = 7 (hex)
##>                  But left half-word and right half-word have to be equal!
##>                  Loop iteration number = 27581
##> Thread number 9: volatile long variable integrity was corrupted:
##>                  full double word = 900000007 (hex)
##>                  left half-word   = 9 (hex)
##>                  right half-word  = 7 (hex)
##>                  But left half-word and right half-word have to be equal!
##>                  Loop iteration number = 1
==> nsk/regression/b4459438 test FAILED


The nsk/regression/b4459438 test source:
===============================================================================
// File: @(#)b4459438.java 1.1 01/11/02 
// Copyright 11/02/01 Sun Microsystems, Inc. All Rights Reserved

public class b4459438 extends Thread {
    static final int STATUS_PASSED = 0;
    static final int STATUS_FAILED = 2;
    static final int STATUS_TEMP = 95;
    static volatile int testResult = STATUS_PASSED;

    static volatile java.io.PrintStream logOut;

    static volatile long volatileLongToTest = 0;
    static int count = 10000000;

    int threadNumber;
    long threadLongKey;

    public b4459438(ThreadGroup threadGroup, String threadName, int threadNumber) {
        super(threadGroup, threadName);
        this.threadNumber = threadNumber;
        long tmpLong = threadNumber;
        threadLongKey = (tmpLong << 32) | tmpLong;
    }

    public void run() {
    
        for(int i = 0; i < count; i++) {
            long copyLong = volatileLongToTest;
            long leftHalfWord = copyLong >>> 32;
            long rightHalfWord = (copyLong << 32) >>> 32;
            if (leftHalfWord != rightHalfWord) {
                logOut.println("##> Thread number " + threadNumber + ": volatile long variable integrity was corrupted:");
                logOut.println("##>                  full double word = " + Long.toHexString(copyLong) + " (hex)");
                logOut.println("##>                  left half-word   = " + Long.toHexString(leftHalfWord) + " (hex)");
                logOut.println("##>                  right half-word  = " + Long.toHexString(rightHalfWord) + " (hex)");
                logOut.println("##>                  But left half-word and right half-word have to be equal!");
                logOut.println("##>                  Loop iteration number = " + i);
                testResult = STATUS_FAILED;;
                return;
            }
            volatileLongToTest = threadLongKey;
        }
    }

    public static int run(String argv[], java.io.PrintStream out) {
        logOut = out;

        logOut.println("==> nsk/regression/b4459438 test LOG:");
        logOut.println("--> This test for #4459438 bug; Category: hotspot; Subcategory: hybrid_interpreter");
        logOut.println("    Synopsis: Accesses to volatile longs don't work in the 64-bit vm\n");

        ThreadGroup b4459438_ThreadGroup = new ThreadGroup("b4459438");
        Object objForWait = new Object();
        Thread[] threadList = new Thread[1];

        int threads = 10;
        for(int i = 1; i < threads; i++) { 
            (new b4459438(b4459438_ThreadGroup, ("" + i), i)).start();
        }
        
        while ( true ) {
            if ( b4459438_ThreadGroup.enumerate(threadList) == 0 ) {
                break;
            }
            synchronized(objForWait) {
                try {
                    objForWait.wait(1000);
                }
                catch (Throwable thrown) {
                    logOut.println("##> Unexpected Exception was thrown by Main Thread:");
                    thrown.printStackTrace(logOut);
                    testResult = STATUS_FAILED;
                    break;
                }
            }
        }

        if ( testResult == STATUS_FAILED ) {
            logOut.println("==> nsk/regression/b4459438 test FAILED");
        }
        else {
            logOut.println("==> nsk/regression/b4459438 test PASSED");
        }
        return testResult;
    }

    public static void main(String argv[]) {
        int testExitStatus = run(argv, System.out) + STATUS_TEMP;
        System.exit(testExitStatus);
    }

}    // end of b4459438 class 


Alexey Gibadullin, ###@###.###

This failure is intermittent and appeared in Merlin since build 81 against 
both Server and Client VMs. The failure was observed on Solx86 and Linux in 
default and -Xcomp modes. However, all failures were revealed just on 
machines with two processors. 

The test used to reveal that failure not in all runs and not against
all Merlin builds. However, it is reproduced regulary against Merlin-b89 
 
    - on Solx86 (Intel: dual-CPU i686 600MHz, RAM 512Mb; OS: Solaris-8) 
      against Server VM in -Xcomp mode;
    - on Linux (Intel: dual-CPU i686 600MHz, RAM 512Mb; OS: Linux/RedHat6.2)
      against Client VM in default mode.
    
See the bug 

    4459438 Accesses to volatile longs don't work in the 64-bit vm
    
that has already been integrated (in merlin-beta2).





Name: abR10010			Date: 04/14/2003


This failure happens again regulary witn Client VM (build 1.5.0-beta-b04, 
compiled mode)
only on Solx86 (Intel: dual-CPU i686 600MHz, RAM 512Mb; OS: Solaris-8).

On one-CPU mashine the test passes as well as it passes on dual-CPU machine
with build 1.5.0-beta-b03.

###@###.### 2003-04-15


======================================================================
The test nsk/regression/b4459438 fail with 1.4.2 JDK at dual CPU machine:

#
[2008-08-12T06:54:48.88] export CLASSPATH
[2008-08-12T06:54:48.88] export PERL
[2008-08-12T06:54:48.88] export PATH
[2008-08-12T06:54:48.88] export TESTLIST
[2008-08-12T06:54:48.88] export HOME
[2008-08-12T06:54:48.88] export DISPLAY
[2008-08-12T06:54:48.88] export LD_LIBRARY_PATH
[2008-08-12T06:54:48.88] TEST_DEST_DIR="b4459438"
[2008-08-12T06:55:08.54] # Actual: TEST_DEST_DIR=b4459438
[2008-08-12T06:55:08.54] TESTNAME="${test_case_name}"
[2008-08-12T06:55:08.54] # Actual: TESTNAME=b4459438
[2008-08-12T06:55:08.54] testName="nsk/regression//b4459438"
[2008-08-12T06:55:08.54] # Actual: testName=nsk/regression//b4459438
[2008-08-12T06:55:08.54] TESTDIR="${test_work_dir}"
[2008-08-12T06:55:08.54] # Actual: TESTDIR=/net/stt-13/export/stt/gtee/global/1.4.2_17/b06/142_VM/38/vm/rhel4-i586/vm-rhel4-i586_11BB2C358EC2008-08-11-21-17-09/stt-robot.Linux.i386/b4459438
[2008-08-12T06:55:08.54] testWorkDir="${test_work_dir}/"
[2008-08-12T06:55:08.54] # Actual: testWorkDir=/net/stt-13/export/stt/gtee/global/1.4.2_17/b06/142_VM/38/vm/rhel4-i586/vm-rhel4-i586_11BB2C358EC2008-08-11-21-17-09/stt-robot.Linux.i386/b4459438/
[2008-08-12T06:55:08.54] export testWorkDir
[2008-08-12T06:55:08.54] tlogOutFile="${test_work_dir}/${test_name}.tlog"
[2008-08-12T06:55:08.54] # Actual: tlogOutFile=/net/stt-13/export/stt/gtee/global/1.4.2_17/b06/142_VM/38/vm/rhel4-i586/vm-rhel4-i586_11BB2C358EC2008-08-11-21-17-09/stt-robot.Linux.i386/b4459438/b4459438.tlog
[2008-08-12T06:55:08.54] testErrFile="${test_work_dir}/${test_name}.err"
[2008-08-12T06:55:08.54] # Actual: testErrFile=/net/stt-13/export/stt/gtee/global/1.4.2_17/b06/142_VM/38/vm/rhel4-i586/vm-rhel4-i586_11BB2C358EC2008-08-11-21-17-09/stt-robot.Linux.i386/b4459438/b4459438.err
[2008-08-12T06:55:08.54] EXECUTE_CLASS="${test_name}"
[2008-08-12T06:55:08.54] # Actual: EXECUTE_CLASS=b4459438
[2008-08-12T06:55:08.54] APPLICATION_TIMEOUT="${TIMEOUT}"
[2008-08-12T06:55:08.54] # Actual: APPLICATION_TIMEOUT=10
[2008-08-12T06:55:08.54] CLASSPATH="${test_work_dir}${PS}${CLASSPATH}"
[2008-08-12T06:55:08.54] # Actual: CLASSPATH=/net/stt-13/export/stt/gtee/global/1.4.2_17/b06/142_VM/38/vm/rhel4-i586/vm-rhel4-i586_11BB2C358EC2008-08-11-21-17-09/stt-robot.Linux.i386/b4459438:/net/stt-13/export/home0/dtf/dtf_ws/suites/142_Suites//vm/src/classes::/export/JDK/j2sdk1.4.2_17/lib/tools.jar:/net/stt-13/export/home0/dtf/dtf_ws/suites/142_Suites/share/harness/tonga/tonga3.0.jar:/net/stt-13/export/home0/dtf/dtf_ws/suites/142_Suites/share/harness/javatest/javatest.jar
[2008-08-12T06:55:08.54] export CLASSPATH
[2008-08-12T06:55:08.54] ${JAVAC}  ${JAVAC_OPTS} -d ${test_work_dir} ${test_work_dir}/b4459438.java
[2008-08-12T06:55:08.54] # Actual: /export/JDK/j2sdk1.4.2_17/bin/javac -d /net/stt-13/export/stt/gtee/global/1.4.2_17/b06/142_VM/38/vm/rhel4-i586/vm-rhel4-i586_11BB2C358EC2008-08-11-21-17-09/stt-robot.Linux.i386/b4459438 /net/stt-13/export/stt/gtee/global/1.4.2_17/b06/142_VM/38/vm/rhel4-i586/vm-rhel4-i586_11BB2C358EC2008-08-11-21-17-09/stt-robot.Linux.i386/b4459438/b4459438.java
[2008-08-12T06:55:08.54] ${JAVA} ${JAVA_OPTS} ${EXECUTE_CLASS} ${TEST_ARGS}
[2008-08-12T06:55:10.06] # Actual: /export/JDK/j2sdk1.4.2_17/bin/java b4459438
[2008-08-12T06:55:10.06] ==> nsk/regression/b4459438 test LOG:
[2008-08-12T06:55:10.23] --> This test for #4459438 bug; Category: hotspot; Subcategory: hybrid_interpreter
[2008-08-12T06:55:10.23]     Synopsis: Accesses to volatile longs don't work in the 64-bit vm
[2008-08-12T06:55:10.23] 
[2008-08-12T06:55:10.23] ##> Thread number 1: volatile long variable integrity was corrupted:
[2008-08-12T06:55:10.23] ##>                  full double word = 100000002 (hex)
[2008-08-12T06:55:10.23] ##>                  left half-word   = 1 (hex)
[2008-08-12T06:55:10.23] ##>                  right half-word  = 2 (hex)
[2008-08-12T06:55:10.23] ##>                  But left half-word and right half-word have to be equal!
[2008-08-12T06:55:10.23] ##>                  Loop iteration number = 102466
[2008-08-12T06:55:10.23] ##> Thread number 3: volatile long variable integrity was corrupted:
[2008-08-12T06:55:10.23] ##>                  full double word = 500000003 (hex)
[2008-08-12T06:55:10.23] ##>                  left half-word   = 5 (hex)
[2008-08-12T06:55:10.23] ##>                  right half-word  = 3 (hex)
[2008-08-12T06:55:10.23] ##>                  But left half-word and right half-word have to be equal!
[2008-08-12T06:55:10.23] ##>                  Loop iteration number = 234442
[2008-08-12T06:55:10.23] ##> Thread number 5: volatile long variable integrity was corrupted:
[2008-08-12T06:55:10.23] ##>                  full double word = 500000003 (hex)
[2008-08-12T06:55:10.23] ##>                  left half-word   = 5 (hex)
[2008-08-12T06:55:10.28] ##>                  right half-word  = 3 (hex)
[2008-08-12T06:55:10.28] ##>                  But left half-word and right half-word have to be equal!
[2008-08-12T06:55:10.28] ##>                  Loop iteration number = 127870
[2008-08-12T06:55:10.28] ##> Thread number 2: volatile long variable integrity was corrupted:
[2008-08-12T06:55:10.28] ##>                  full double word = 100000002 (hex)
[2008-08-12T06:55:10.28] ##>                  left half-word   = 1 (hex)
[2008-08-12T06:55:10.28] ##>                  right half-word  = 2 (hex)
[2008-08-12T06:55:10.28] ##>                  But left half-word and right half-word have to be equal!
[2008-08-12T06:55:10.28] ##>                  Loop iteration number = 171706
[2008-08-12T06:55:10.28] ##> Thread number 6: volatile long variable integrity was corrupted:
[2008-08-12T06:55:10.28] ##>                  full double word = 800000006 (hex)
[2008-08-12T06:55:10.28] ##>                  left half-word   = 8 (hex)
[2008-08-12T06:55:10.28] ##>                  right half-word  = 6 (hex)
[2008-08-12T06:55:10.28] ##>                  But left half-word and right half-word have to be equal!
[2008-08-12T06:55:10.28] ##>                  Loop iteration number = 240439
[2008-08-12T06:55:10.28] ##> Thread number 8: volatile long variable integrity was corrupted:
[2008-08-12T06:55:10.28] ##>                  full double word = 800000006 (hex)
[2008-08-12T06:55:10.28] ##>                  left half-word   = 8 (hex)
[2008-08-12T06:55:10.28] ##>                  right half-word  = 6 (hex)
[2008-08-12T06:55:10.28] ##>                  But left half-word and right half-word have to be equal!
[2008-08-12T06:55:10.28] ##>                  Loop iteration number = 97107
[2008-08-12T06:55:10.28] ##> Thread number 7: volatile long variable integrity was corrupted:
[2008-08-12T06:55:10.28] ##>                  full double word = 800000006 (hex)
[2008-08-12T06:55:10.28] ##>                  left half-word   = 8 (hex)
[2008-08-12T06:55:10.28] ##>                  right half-word  = 6 (hex)
[2008-08-12T06:55:10.28] ##>                  But left half-word and right half-word have to be equal!
[2008-08-12T06:55:10.28] ##>                  Loop iteration number = 0
[2008-08-12T06:55:10.28] ##> Thread number 9: volatile long variable integrity was corrupted:
[2008-08-12T06:55:10.28] ##>                  full double word = 800000006 (hex)
[2008-08-12T06:55:10.28] ##>                  left half-word   = 8 (hex)
[2008-08-12T06:55:10.28] ##>                  right half-word  = 6 (hex)
[2008-08-12T06:55:10.28] ##>                  But left half-word and right half-word have to be equal!
[2008-08-12T06:55:10.28] ##>                  Loop iteration number = 139749
[2008-08-12T06:55:10.28] ##> Thread number 4: volatile long variable integrity was corrupted:
[2008-08-12T06:55:10.28] ##>                  full double word = 800000006 (hex)
[2008-08-12T06:55:11.24] ##>                  left half-word   = 8 (hex)
[2008-08-12T06:55:11.24] ##>                  right half-word  = 6 (hex)
[2008-08-12T06:55:11.24] ##>                  But left half-word and right half-word have to be equal!
[2008-08-12T06:55:11.24] ##>                  Loop iteration number = 32551
[2008-08-12T06:55:11.24] ==> nsk/regression/b4459438 test FAILED
[2008-08-12T06:55:11.24] # Test level exit status: 97
[2008-08-12T06:55:12.25]

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b10 VERIFIED IN: tiger
14-06-2004

EVALUATION Not reproducible in rc1 b86. I tried both dual and quad processor machines (nabisco.east and mellow-yellow.east). The original sparcv9 bug was due to bad code in the interpreter. The x86 interpreter code seems to be ok. It loads and stores volatile fields through the fp stack. ###@###.### 2001-11-15 Reproduced via bug 4432655. See 'Suggested Fix'. ###@###.### 2003-06-12 Name: elR10090 Date: 09/12/2003 I've tried the test "b4459438" against Tiger-b18 and -b19; the problem seems not reproducable for these latest builds. ======================================================================
11-06-2004

SUGGESTED FIX There are two problems here. 1. The code generated by the server compiler is bad. A ConvL2I of a volatile LoadL is being replaced by a LoadI. If there is more than one use of the LoadL, more than one load of a supposedly atomic value will be generated. See the test program in bug 4432655. 2. Long fields can be aligned on 4-byte boundaries on x86 platforms (see globalDefinitions_i486.hpp). If such a long field is split across a cache line, two separate loads will occur, one for each half. ###@###.### 2003-06-12
12-06-2003