Stack Overflow

Discussions related to Visual Prolog
Martin Meyer
VIP Member
Posts: 280
Joined: 14 Nov 2002 0:01

Stack Overflow

Unread post 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
Paul Cerkez
VIP Member
Posts: 94
Joined: 6 Mar 2000 0:01

Unread post 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.
AI Rules!
P.
Martin Meyer
VIP Member
Posts: 280
Joined: 14 Nov 2002 0:01

Unread post 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
User avatar
Thomas Linder Puls
VIP Member
Posts: 1178
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

Thank you, we will look at the problem.
Regards Thomas Linder Puls
PDC
Paul Cerkez
VIP Member
Posts: 94
Joined: 6 Mar 2000 0:01

Unread post by Paul Cerkez »

Thanks Martin, that makes sense.
AI Rules!
P.
Post Reply