| I have recently been doing some compiler development work based
| on hugs98-990222. Sometimes, I encounter strange internal errors,
| the source of which appears to be a garbage collection problem. It
| looks to me like the default "gcc -g -O2" is enough to hide some
| pointers from the garbage collector (they probably get passed in
| registers). Removing -O2 cures the problem. Has anyone else found
| this?
Yes, I've experienced very similar problems myself right from the
early days with Gofer; you might notice, for example, that certain
critical components of the Hugs system have special command lines
in the makefile to ensure that they are compiled without optimization.
Internally, Hugs makes some assumptions about the C runtime model that
it has no right to make. It turns out, however, that the assumptions
are usually valid. In fact it is pretty amazing that things work as
well as they do most of the time! Alas, sometimes, fancy optimizers
change the code in ways that break those assumptions.
The problem seems to be very platform/compiler specific, with Sun
machines always seeming particularly vulnerable. My first response
when anyone encounters such problems is to try compiling without
optimization, which is precisely what you have done.
I guess we should make more special cases in the Makefile to reduce
the chances of such problems.
All the best,
Mark