possible bug in Eq of packedStrings

Simon Marlow simonmar@microsoft.com
Mon, 28 Apr 2003 11:26:40 +0100


 
> I think I've come across a bug in the (==) function of 
> PackedString, but
> it's hard to reproduce.  I'm attaching a set of files that 
> hopefully will
> reproduce the problem.  My assumption is that if two packed 
> strings are
> unequal, then when their unpacked versions must also be 
> equal.  This is, of
> course, assuming one starts with the packed versions, since packing of
> strings may be lossy...

This does appear to be a bug in the PackedString library.  It appears that hGetPS doesn't zero-terminate the string, but the
comparison code expects the strings to be zero-terminated.  I'm not sure who's at fault here.

The right fix is to use Data.PackedString instead of PackedString (no package lang required).  Data.PackedString is a complete
re-implementation and doesn't suffer from the bug you reported (that's not to say it doesn't have different bugs though!).

Cheers,
	Simon