I have encountered a really weird issue in the current version of PLT scheme: <br>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:<br>
<br>- I just keep pressing ctrl+T in drscheme (run) and I get faulty results every now and then<br>- there's no pattern as to when the results go wrong<br>- the program uses no concurrency, no special libraries, only the basic stuff from the scheme and scheme/base libs<br>
- the program uses no randomisation, no gui<br>- the program uses no input, output, nor any OS-related primitives<br><br>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.<br>
<br>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). <br>
<br>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.<br>
<br>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?<br><br><br>Best regards,<br><font color="#888888">Marcin</font>