Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Zeg-Vok

Stack Overflows?

Recommended Posts

Most likely a noob question, but what exactly are they? And how would one prevent them from happening?

Share this post


Link to post

Too many nested function calls. Usually happens with recursive functions when the tree it walks through is too deep.

Share this post


Link to post

Actually some not entirely internal functions in DOOM could cause stack overflows too. The Look and Chase codepointers, if called from the wrong frames, would cause this easily. Here's why, as an illustration of how these kinds of things can happen:

Let's say these are the thing's frames (in EDF just for the hell of it), as two different examples.

frame foo1 { cmp = "AAAA|A|*|10|Chase|@this" } // thing's spawnstate

frame foo2 { cmp = "AAAA|A|*| 4|Look |@next" } // thing's seestate
Problem #1: Chase called from spawnstate. The thing's target is NULL, since it has never seen a target yet, so the code directs it to return to its spawnstate (monsters with no target "fall asleep"). The spawnstate codepointer gets called again. Chase. Chase will mutually recurse with P_SetMobjState forever.

Problem #2: Look called from seestate. Assuming the thing has a valid target, if it calls Look, the code directs it to go to its seestate (aka first walking frame for you DeHackEd people). It's already in its first walking frame, though, so it's going to call Look again. Look will mutually recurse with P_SetMobjState forever.

Share this post


Link to post

Hmmm, well, I do have a projectile with A_Chase in its spawnstate, but it still works, but Ill assume that since I only get stack overflows when I test out my weapons in a bot DM, there might be too much going on

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×