Stack Overflow

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

Stack Overflow

Unread post by Martin Meyer » 22 Jan 2015 12:08

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: 202
Joined: 6 Mar 2000 0:01

Unread post by Paul Cerkez » 22 Jan 2015 13:40

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: 289
Joined: 14 Nov 2002 0:01

Unread post by Martin Meyer » 22 Jan 2015 15:10

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: 1622
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 22 Jan 2015 16:13

Thank you, we will look at the problem.
Regards Thomas Linder Puls
PDC

Paul Cerkez
VIP Member
Posts: 202
Joined: 6 Mar 2000 0:01

Unread post by Paul Cerkez » 22 Jan 2015 16:54

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

Post Reply