[clean-list] 65537 on Linux

John van Groningen johnvg at cs.ru.nl
Wed Aug 15 15:35:11 MEST 2007


lethevert wrote:
>I noticed an interesting thing in Clean 2.2 on Linux.
>
>I created a module Test5Add as the following.
>
>==Test5Add.dcl=====================================================
>definition module Test5Add
>
>add :: Int Int -> Int
>
>==Test5Add.icl=====================================================
>implementation module Test5Add
>
>import StdInt
>
>add :: Int Int -> Int
>add a b = a + b
>
>===================================================================
>
>Then I made a main module.
>
>==Test5.icl========================================================
>module Test5
>
>import StdEnv, Test5Add
>
>Start = foldl add 0 (take 65537 (repeat 1))
>
>===================================================================
>
>Then run the program but it did not return.
>I changed the number 65537 to 65536, then it returned within a second.
>
>I tried it on Windows environment and both programs returned in a second.
>
>I wonder why this happens. Is it a bug?

This is caused by a stack overflow, the program needs a stack of
more than 512k. If you increase the stack size by passing -s 1m
to the application or clm, the program will return.

The program should have reported a stack overflow. However the optimizer
of gcc now eliminates some assignments to the sigcontext in the exception
handling code, causing an infinite loop instead.

I will make some patches available to fix this, hopefully on friday,
otherwise next week.

Kind regards,

John van Groningen


More information about the clean-list mailing list