Alexander Krauss wrote:
The following code leads to a segmentation fault when fed into polyml:
fun REPEAT t r c = REPEAT t c (t r c);
fun I x = x;
fun f r c n = if n <= 0 then r n else c n;
fun g x = REPEAT f I I x;
g 0;
The code really doesn't make any sense... but assuming that polyml
should never segfault, this must be a bug.
Any ideas why this occurs? Does it have to do with the value restriction
in some form?
The problem is that this contains an infinite loop building a longer and
longer list of closures. The mark phase of the garbage collector marks
this data structure recursively and it is possible for it to run out of
stack. On Unix that causes a segmentation fault. That's unfortunate:
it would be nice to avoid this but it would have significant costs on
normal programs.
David
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml