[plt-scheme] Unpredictable behaviour of plt Scheme 4.1.5

From: Marcin Karpinski (marcin.karpinski at gmail.com)
Date: Fri Apr 3 18:55:52 EDT 2009

I have encountered a really weird issue in the current version of PLT
scheme:
I'm implementing a compiler which takes sexps as input, performs
transformations (making occasional use of set!) and outputs the result to
repl (sexps + structures). For the very same input the program returns a
faulty result every few times I run it. Normally, I would consider it my own
bug but:

- I just keep pressing ctrl+T in drscheme (run) and I get faulty results
every now and then
- there's no pattern as to when the results go wrong
- the program uses no concurrency, no special libraries, only the basic
stuff from the scheme and scheme/base libs
- the program uses no randomisation, no gui
- the program uses no input, output, nor any OS-related primitives

So my guess, is that if the bug is mine, I should at least be getting the
same output every time I press ctrl+T.

The faulty results are related to the following: I've implemented ML type
inference and I have I module implementing unification of terms with the use
of the union-find data structure. The union-find algorithm makes extensive
use of set! on mutable structure fields (set-struct-name-field-name!) in
order to connect type variables in different ways. Variables are stored
sometimes in mutable hash tables. As it seems to me, the bug is related to
certain type variables getting connected in a wrong way resulting in a
unification error (as if there was a real typing error).

I have a test input that I know should go through but every few executions
the unifier reports an error. The only reasonable cause that comes to my
mind is some flaw in garbage collection but I don't know how to suppress it
or to take a closer look at it.

I know this is a pretty high-level explanation, but I can't for now isolate
the problem to few lines of code. Any clues?


Best regards,
Marcin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090403/e287419c/attachment.html>

Posted on the users mailing list.