Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6730716
Votes 0
Synopsis nulls from two unrelated classes compare not equal
Category hotspot:compiler2
Reported Against
Release Fixed hs14(b04)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs
Submit Date 28-JUL-2008
Description
FULL PRODUCT VERSION :
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Server VM (build 10.0-b23, mixed mode)


FULL OS VERSION :
Linux 2.6.25.6-27.fc8 #1 SMP Fri Jun 13 16:38:52 EDT 2008 i686 i686 i386 GNU/Linux


EXTRA RELEVANT SYSTEM CONFIGURATION :
We reproduced this problem on several machines. Some are running 32 bit Linux on 64 bit cpu's. All have in common that they are multi-core Linux machines
processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      :  customer (R) Core(TM)2 CPU          6400  @ 2.13GHz
stepping        : 2
cpu MHz         : 2128.043
cache size      : 2048 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
bogomips        : 4265.81
clflush size    : 64


A DESCRIPTION OF THE PROBLEM :
Code below fails during runtime after loop 5000. This works fine on single-core machines, and on multi-core machines on Windows, but fails on multi-core machines on Linux. This using JDK 1.6


THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the code below, compile and run


EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:
  Program prints number of cpus and exits normally
Actual using jdk 1.6 on multi-core Linux machines:
Number of cpus = 2
Failed at i = 5001

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Failed at i = 5001

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class Class1
{
  private static  boolean   compare(ThreeClass threeClass, FiveClass fiveClass)
  {
    for (;;)
    {
      if  (threeClass == null || fiveClass == null)
      {
        return (Object)threeClass == (Object)fiveClass;
        // Using this line it works
        //return threeClass == null && fiveClass == null;
      }
      threeClass = threeClass.next;
      fiveClass = fiveClass.next;
    }
  }

  public static void main(String[] args)
  {
    System.out.println( "Number of cpus = " + Runtime.getRuntime().availableProcessors() );
    ThreeClass threeClass = new ThreeClass();
    threeClass.next = null;
    FiveClass fiveClass = new FiveClass();
    fiveClass.next = null;
    
    for ( int i = 0; i < 10000; i++ )
    {
      if ( !Class1.compare(threeClass, fiveClass) )
      {
        System.out.println( "Failed at i = " + i );
        break;
      }
    }
  }
}
class ThreeClass
{
  ThreeClass next;
}
class FiveClass
{
  FiveClass next;
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Replace the code
        return (Object)threeClass == (Object)fiveClass;
with the code:
        return threeClass == null && fiveClass == null;
Posted Date : 2008-07-28 22:57:47.0
Work Around
N/A
Evaluation
The compiler "proves" that objects from unrelated classes are not equal.  Usually,
this is true, except when both object are null.
Posted Date : 2008-07-29 16:52:14.0

http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/ce93a51457ae
Posted Date : 2008-08-20 14:31:21.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang