Mantis - Squeak
Viewing Issue Advanced Details
7260 VM minor always 01-04-09 20:10 04-18-10 22:06
nicolas cellier  
lewis  
normal  
closed 3.10  
fixed  
none    
none  
0007260: some Float comparison primitives don't handle Nan correctly
"These should all be false, but due to primitive naive implementation some are true"
{
2.0 >= Float nan.
2.0 > Float nan.
2.0 < Float nan.
2.0 <= Float nan.
}.
"#(true false false true)"

"After correcting in image Smalltalk code, i correctly have:"
{
2000000000000 >= Float nan.
2000000000000 > Float nan.
2000000000000 < Float nan.
2000000000000 <= Float nan.
}.
 #(false false false false)

"But this doesn't happen with 2.0, because of the primitive..."
Correction is very simple:

primitiveFloatGreaterOrEqual should call a primitiveFloatGreaterOrEqualToArg.
because, using Magnitude implementation is WRONG:

(2.0 >= Float nan) ~= (2.0 < Float nan) not

With nan, order relation is not total but partial;
thus notLessThan: is no more an order relationship...
It cannot be used as equivalent to >=
This is the same bug as 0006719
I duplicate because it requires both image and vm correction
This report is concerning the VM.

same kind of correction required for primitiveFloatLessOrEqual
related to 0006719closed nicolas cellier Float nan comparison is broken 
 M7260-primitiveFloatCompareNan-Test-nice.1.cs [^] (1,308 bytes) 01-04-09 20:41
 M7260-primitiveFloatCompareNan-Patch-nice.1.cs [^] (1,503 bytes) 01-04-09 20:41
 M7260-primitiveSmallIntegerCompareNan-Test-nice.1.cs [^] (960 bytes) 01-04-09 21:02
 M7260-primitiveSmallIntegerCompareNan-Patch-nice.1.cs [^] (1,656 bytes) 01-04-09 21:03
 M7260-bytecodePrimGreaterEqual-update-dtl.1.cs [^] (1,598 bytes) 07-01-09 23:11
 M7260-FloatCompareNonRegressionTest-nice.2.cs [^] (2,350 bytes) 07-06-09 01:08

Notes
(0012890)
nicolas cellier   
01-04-09 21:06   
Hehe, the patch for fixing Float primitive does not solve the problem, <= and >= are very special selector with very special handling...

#bytecodePrimLessOrEqual and #bytecodePrimGreaterOrEqual must also be changed...

So please, download the two patches and two tests I proposed.
(0013135)
lewis   
06-12-09 11:37   
Included in VMMaker-dtl.123 on SqueakSource
(0013140)
lewis   
07-01-09 16:54   
Reopening issue base on this from vm-dev list:

On Wed, Jul 01, 2009 at 08:32:18AM -0700, Andreas Raab wrote:
>
> Ouch. Yeah, I'd say that's right...
>
> Bert Freudenberg wrote:
> >
> >I just noticed that
> >
> >bytecodePrimGreaterOrEqual
> > ...
> > aBool := self primitiveFloatLess: rcvr thanArg: arg.
> > successFlag ifTrue: [^self booleanCheat: aBool not].
> >
> >got changed to
> >
> >bytecodePrimGreaterOrEqual
> > ...
> > aBool := self primitiveFloatGreaterOrEqual: rcvr toArg: arg.
> > successFlag ifTrue: [^self booleanCheat: aBool not].
> >
> >but shouldn't that be
> >
> >bytecodePrimGreaterOrEqual
> > ...
> > aBool := self primitiveFloatGreaterOrEqual: rcvr toArg: arg.
> > successFlag ifTrue: [^self booleanCheat: aBool].
> >
> >and similarly for bytecodePrimLessOrEqual?
> >
> >- Bert -
> >
(0013141)
lewis   
07-01-09 23:17   
Added M7260-bytecodePrimGreaterEqual-update-dtl.cs to VMMaker-dtl.124 to correct error on previous patch.
(0013154)
lewis   
07-06-09 01:38   
Fix included in VMMaker-dtl.124 confirmed by Nicolas Cellier on vm-dev, with additional unit tests added to this bug report.