JDK-4965430 : Inconsistent results when comparing string references
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 1.4.2_02
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_8
  • CPU: generic
  • Submitted: 2003-12-09
  • Updated: 2004-04-30
  • Resolved: 2004-01-21
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
1.4.2_05 05Fixed
Description
A piece of code that is written as follows:

String s = "";
while (s == "") { }

...is seen to produce inconsistent results when it is embedded within a highly threaded program having thousands of lines of code.  Under IBM's VM, this always evaluates as TRUE.  With Sun's VM, the loop is occasionally ignored.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.2_05 generic tiger-beta2 FIXED IN: 1.4.2_05 tiger-beta2 INTEGRATED IN: 1.4.2_05 tiger-b35 tiger-beta2 VERIFIED IN: 1.4.2_05
14-06-2004

EVALUATION This bug reproduces only with "-server -d64" on 1.4.1_xx, 1.4.2_xx, 1.5.0-beta-b30. If I exclude "WhileLoopTest.<init>" method in .hotspot_compiler then problem never reproduces and the same has been confirmed from customer. One more observation is, if I compile testcase src files with "1.4.1 javac" compiler and run with 1.4.1_xx(06, 07), 1.4.2_xx (03,04), 1.5.0-beta-b30 JVMs then problem ALWAYS REPRODUCES. However, If I compile testcase src files with "1.4.2 javac" compiler and run with 1.4.2_xx (03,04), 1.5.0-beta-b30 JVMs then problem NEVER REPRODUCES. But it does REPRODUCE with 1.4.1_xx (07, 06) JVM. It seems for customer it is not possible to compile their application with 1.4.2 javac compiler and then run. We need to address this with 1.4.1, 1.4.2, 1.5 JVMs since there could be pre-compiled classes with 1.4.1 javac compiler and run with any of these JVMs.
11-06-2004

WORK AROUND Use: 1) s.equals("") instead of s=="", 2) s.length()==0 instead of s=="", 3) only -server compiler without -d64. 4) exclude method from compilation in .hotspot_compiler as exclude WhileLoopTest <init>
11-06-2004

SUGGESTED FIX --- subnode.cpp Thu Dec 18 10:27:39 2003 *************** *** 547,558 **** // Unknown inputs makes an unknown result if( r0->singleton() ) { ! jint bits0 = r0->get_con(); if( r1->singleton() ) return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT; return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC; } else if( r1->singleton() ) { ! jint bits1 = r1->get_con(); return ( r0->_ptr == TypePtr::NotNull && bits1==0 ) ? TypeInt::CC_GT : TypeInt::CC; } else return TypeInt::CC; --- 547,558 ---- // Unknown inputs makes an unknown result if( r0->singleton() ) { ! intptr_t bits0 = r0->get_con(); if( r1->singleton() ) return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT; return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC; } else if( r1->singleton() ) { ! intptr_t bits1 = r1->get_con(); return ( r0->_ptr == TypePtr::NotNull && bits1==0 ) ? TypeInt::CC_GT : TypeInt::CC; } else return TypeInt::CC;
11-06-2004