Page 1 of 1

Stack Overflow

Posted: 22 Jan 2015 12:08
by Martin Meyer
Hi Thomas,

there is a -low importance- issue about stack overflows. In my tries (using 7501) below predicate test has worked out in 32 bit mode, but crashed in 64 bit mode.

Code: Select all

class predicates     test : (). clauses     test() :-         try floodStack()         catch _ do             stdIo::write("I'll be back\n")         end try,         stdIo::write("I got back").   class predicates     floodStack : (). clauses     floodStack() :-         floodStack(),         floodStack().
Best regards
Martin

Posted: 22 Jan 2015 13:40
by Paul Cerkez
curious, on the first call to floodStack(), it should have gone into an infinite loop, recursively calling itself until it eventually crashed.

I'm surprised it worked in the 32bit.

Posted: 22 Jan 2015 15:10
by Martin Meyer
Yes, Paul, it goes into an infinite loop on the first call of floodStack to itself.

The call is not tail recursive, because it is followed by a second one (which however actually will never be reached). Because the call is not tail recursive, each execution of it eats up a further piece of stack.

When the stack is exhausted, the "infinite" loop must stop somehow. In 32 bit mode it raises a system exception with extra-info telling that it is a stack overflow. The exception is caught in the test-predicate, so that it succeeds in the end.

But in 64 bit mode it seems, that it does not raise the system exception, when the stack is exhausted, but just crash the application.

Regards
Martin

Posted: 22 Jan 2015 16:13
by Thomas Linder Puls
Thank you, we will look at the problem.

Posted: 22 Jan 2015 16:54
by Paul Cerkez
Thanks Martin, that makes sense.