English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. Blitz Basic (http://eab.abime.net/forumdisplay.php?f=126)
-   -   Out of Stack Space Error (http://eab.abime.net/showthread.php?t=105862)

Havie 17 February 2021 00:07

Out of Stack Space Error
 
Hi - so have discovered I have a game killing error - out of stack space.

At first I thought it might be because I am jumping out of for next loops and I read the manual that said I needed to pop for if this is the case. I have found them all I think.

Does anyone know what else might cause this error so I can root it out! Have checked a much earlier version of my Space Invaders and I still get the error so it's been there for a while but only shows itself if you play the game through a few times.

Thanks in advance for any help you can offer.

Daedalus 17 February 2021 10:12

I've never run into it myself - are you doing any sort of recursion? Jumping with Gosub without returns? Jumping out of a Select block without returning? It sounds like something's not happening in the right order, and you're just building a massive stack without clearing it.

Havie 17 February 2021 14:24

Thanks - that's what I am think. Error doesn't even appear int he Blitz manual that I have! No selects but some gosubs (sorry bit old school as learnt to program from the ZX Spectrum manual).

I'll have to work my way slowly through the code - it's something that has always been there so I may be able to go back to earlier (less spaghetti) code to hunt it out!

DamienD 17 February 2021 15:29

I'm sure I had this when looking at Brick Nash's Streets of Rage.

...nope, just checked, it was:

Quote:

Originally Posted by DamienD (Post 1448538)
  • Kept getting errors about "variable buffer to small" when testing, had to increase to "300000".

Ooops, and that was AMOS; not Blitz Basic :blased

Daedalus 17 February 2021 15:46

There's nothing wrong with a Gosub (or even a Goto, for that matter) if it's used responsibly and with good reason ;) They're a bit old skool and can lead to difficult to debug situations, weird bugs and tricky to follow code, but they're also faster than using functions, and in game terms on stock hardware, that speed difference can be important.

Make sure every Gosub is terminated with a Return, and that if you leave the Gosub for anything, you Return back into it before Returning to the previous point. If you really need to, you can Pop out of a Gosub stack, but I think such a situation could easily be handled some other way.

Havie 17 February 2021 15:52

Quote:

Originally Posted by DamienD (Post 1463059)
I'm sure I had this when looking at Brick Nash's Streets of Rage.

...nope, just checked, it was:


Ooops, and that was AMOS; not Blitz Basic :blased

Good try! :p

Havie 17 February 2021 15:52

Quote:

Originally Posted by Daedalus (Post 1463065)
There's nothing wrong with a Gosub (or even a Goto, for that matter) if it's used responsibly and with good reason ;) They're a bit old skool and can lead to difficult to debug situations, weird bugs and tricky to follow code, but they're also faster than using functions, and in game terms on stock hardware, that speed difference can be important.

Make sure every Gosub is terminated with a Return, and that if you leave the Gosub for anything, you Return back into it before Returning to the previous point. If you really need to, you can Pop out of a Gosub stack, but I think such a situation could easily be handled some other way.

Thanks - will track them all through...


All times are GMT +2. The time now is 17:36.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.

Page generated in 0.05357 seconds with 11 queries