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 : Intel(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;
|