[plt-scheme] Re: Unpredictable behaviour of plt Scheme 4.1.5

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Apr 3 20:45:25 EDT 2009

On Apr  3, karpik wrote:
> unfortunately not, I use hash tables just as maps and sometimes as
> storage. No part of the code depends on the order of items in the
> hash table...

Well, if you do any kind of mapping on the hash table, you may
introduce a dependency on the order which you don't know about.  It's
just that the most obvious source of potential trouble in your message
is "hash tables" and "extensive use of set!".  It might not be a
direct use of `hash-map' -- in your message you refer to a
`union-find', perhaps that depends somehow on the order of items in
the table?

To try out these things, I would try to: (a) find any iteration over a
hash table and try to make it go over it in some ordered way;
(b) alternatively, I'd try to switch to a deterministic dictionary
implementation to see if the problem is in the hash table to begin
with; (c) print various objects in the algorithm, and compare a faulty
output with a good one (for this, I'd add an `identifier' field to
structs, and make each struct allocation use a counter, so I can
identify the structs).

BTW, I doubt that the problem is with the GC -- these kind of problems
usually look much more serious than "wrong result"...  But if you're
using a weak hash table then you're introducing another source of
potential problems -- with results that might depend on GC timings.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.