On Thu, 9 Dec 1999, Michael Marte wrote:

> I am using Hugs98 (september release) together with the pretty printer
> combinators by Hughes and Jones.
> When printing a large structure, Hugs aborts with the message GC
> Blackhole. The program works fine for smaller structures.
> The problem occurs with all renderes.
> I am quite sure that this is a pretty printing problem because the program
> works fine when using a simple derived Show instance.
> The problem occurs with ghc 4.05 , too. When printing a large structure,
> the program crashes due to a bus error.

Upon this call for help Alastair Reid has provided a version of 
the pretty printing library with some space leaks fixed.
However, the problem persisted.

Meanwhile, I found some time to observe the output of Hugs.
It turned out that the execution stopped because of a control stack
overflow, and, after printing some stack (or heap?) dump, a
GC Blackhole was reported.

The control stack overflow occured in the evaluation of the second
argument to some call of nilAboveNest. The argument was a hugs structure
consisting of nested calls to primMinusInt and +. In consequence I change
the code in order to force the evaluation of + and - (by means of $!).
Now, luckily, the pretty printer works (with Hugs 000201-pre-rel) and is
able to print huge structures. (I use it with HaXml to exchange data
between modules.) See the attachments for the code.

Please note that I do not know what I did. I did not try to understand the
pretty printer and I have no idea how the changes might affect the
operational behaviour of some user program or of the pretty printer
itself. I just looked for applications of + and - and forced evaluation.

In my opinion, since the pretty printer is becoming a basic brick of other
libraries, its operational behaviour should be investigated closer.

Kind regards,
Michael Marte

gzipped fixed Pretty.lhs

Reply via email to