Dear list,
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?
Thanks, Alex
On Windows PolyML 5.2.1 gives the following warning before the segfault:
The type of (it) contains a free type variable. Setting it to a unique monotype.
Using MosML 2.01 it does not segfault, though.
Regards, Andras Pahi
----- Original Message ----- From: "Alexander Krauss" krauss@in.tum.de To: polyml@inf.ed.ac.uk Cc: "Armin Heller" ArminHeller@t-online.de Sent: Monday, November 17, 2008 6:14 PM Subject: [polyml] obscure segfault
Dear list,
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?
Thanks, Alex _______________________________________________ polyml mailing list polyml@inf.ed.ac.uk http://lists.inf.ed.ac.uk/mailman/listinfo/polyml
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