Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / 'Stack overflow error'?

Author
Message
FROGGIE!
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: in front of my computer
Posted: 26th Aug 2004 02:02
Whats it mean?

I should have changed my signature when asked
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 26th Aug 2004 02:23 Edited at: 26th Aug 2004 02:26
Can you post your code?

It usually means what you're doing is too complex that DB runs out of space to put all the data you're manipulating.

Get 15 new commands, all the date / time commands left out of DBPro for free!
DOWNLOAD PLUGINS HERE: http://www.davidtattersall.me.uk/ and select "DarkBasic"
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 26th Aug 2004 03:18
it means you did something like

point1:
gosub point2
point2:
gosub point1

eventualy the computer will run out of stack, the memory it uses to store the return points after every gosub, if you do enough gosubs and don`t return, or miss returning and do a goto instead, eventualy the system will run out of space to store all those unused return locations that never got used, just added to over and over, you MUST return properly from all the gosubs (or functions) you call, if your program has just one unused return per loop then after just a few seconds your gonna run out of stack, not a good error to get and normaly happens when you are using recursion and go way too deep.

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Aug 2004 14:02
actually, i doubt that would cause an overflow stack error. Cause you basically have a do-loop. It's common in recursive function routines.

"eureka" - Archimedes
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 26th Aug 2004 18:45 Edited at: 26th Aug 2004 18:48
@Phaelax: actualy that wouldn`t compile, cos its in psuedocode, if you modify it so it should compile then in Pro it just fails silently, drops back to the ide and nothing happens, if you compile the following in classic then you get a stack overflow, read the code again, its not a do-loop its a gosub calling a gosub calling a gosub.... etc, so the machine has to keep storeing the return point for all those gosubs, waiting for the code to return from all of them and it never does, just keeps calling more gosubs and storeing the return locations on the stack, Pro won`t even compile it (although its legit code) but classic gives a stack overflow error (as I said it would).

point1:
gosub point2
return <<<< this never gets executed
point2:
gosub point1
return <<<<< this never gets executed

gives (in DB classic)

Runtime error at line 2. stack overflow error.

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Aug 2004 12:22
Runs exactly as I would expect a DO loop to run. No crash, no errors.



I know what you're saying, and normally I would agree. But this code has yet to produce the error on me.

"eureka" - Archimedes
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Aug 2004 20:37
umm, Pro doesn`t seem to admit it`s stack is full, and printing evey loop will slow it down so much it would take ages to use up a megabyte, but it reports a stack full in DB classic, this snippet

sync on:sync rate 0
set text opaque
point1:
a=system smem available()
gosub point2
return

point2:
b=system smem available()
if b<a
print b
sync
endif
gosub point1
return

shows memory shrinking and then it falls back into the editor, so presumably the memory use is the storage taken up by return addresses growing, and the silent fall back into the editor is the point where you should get a stack error, anyway, you definitley do not want to write your code on the assumption that calling an infinite number of gosubs is ok, cos it isn`t by any stretch of the imagination, if only because of the memory leak caused by all those return addresses being stored and never retrieved.

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Aug 2004 03:36
Suppose it would take quite awhile to fill 1gb of memory.

"eureka" - Archimedes
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 28th Aug 2004 04:20
just a little while , but it could be a problem if it isn`t released at the end of the program run, and if you where doing something with recursive methods (flood fill, pathfinder, maze generation) you could end up running out of memory no matter how much you have, it could be that Lee stopped using the stack for return adresses and swapped to some memory manager of his own, whatever the case it fails to report an error when it gets out of bounds, ought to be seen to (could account for some of these silent falls back into the desktop you get with pro).

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Aug 2004 09:03
Only recursion I've ever had to do was with my JTree object in java, for reading in folders and such. Not done yet, but my collision system will be recursive. Just gotta make sure it doesn't get stuck in a loop.

"eureka" - Archimedes

Login to post a reply

Server time is: 2025-05-25 10:40:35
Your offset time is: 2025-05-25 10:40:35