Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Stack level too deep, what can cause it?

Atoa

Member

Well i'm having an problem with my battle system.

It's an strange stack error.

I know that aliases can cause it if the game is restarted with F12.
I know how to fix it, and that's not the problem.

The problem is a stack error that occur with the game running, but the strange part is that it points an random line in the script editor.
So i cant find what is wrong.

So i would like to know what causes it, so i can figure out how to fix the bug.
 
I think it points at a random line because that's the line it stopped on when it decided "okay I've been past this point way too many times now".
That gives you a little something to work with, though, whatever method that line is inside is part of the loop it's stuck in. Is that method aliased? And if not, what method calls it, and what methods does it call? Cause somewhere A calls B, B calls C, and C calls A, or something along those lines.
 
stack error is a command that ran in loop like 100 times. never shows random line. use what editor shows to find error. might be part of the command that is running or command u are looking for
 
Is this happening only when you hit F12 or does it happen other times? This prevents ONLY the silly F12 error, it doesn't prevent other unrelated Stack Level Too Deep errors so if you get one unrelated to F12 its actually a problem somewhere you need to figure out how to fix. You can place this anywhere so long as it is above 'main' at the bottom of the editor it'll work fine.

Code:
if @f12_fix.nil?

#===============================================================================

# ** F12_Fix

#===============================================================================

f12 = Thread.new {

  @f12_fix = Win32API.new('user32', 'keybd_event', 'LLLL', '')

  @f12_fix.call(0x7B,0,0,0)

  sleep(0.1)

  @f12_fix.call(0x7B,0,2,0)

}

f12.priority = 1

end

Good luck :thumb:
 

Atoa

Member

@SolstICE
No you wrong, if you doubt , i will send you the old demo of my projetc.

How choosing the escape command in an battle can cause stack with an array push in the game actor class? then if ti change anything in any other part of the script, it's points another line.

@Kain Nobel
It happens always at the same point, even if the game isn't restarted.
It was on my batte system, always the escape command fail.

I had to remove a lot of methods and rewrite them, it solved now, but it's still an mystrey, since i did almost the same things.

I will study the old demo later to discover what caused it.
 

Atoa

Member

it's not a script i added, it's an script i'm making.

You said that stack erro never shows random lines, but it's not true.

And the line the error points has abslotely no reationshinp with the escape comand.
It point lines in different methods with no logic on it.

The last one i get was a line "@value = Integer"
how can setting an istance equal an Integer cause stack error? ¬¬

It's more likely what BwdYeti said, it enters on loop and when it get "tired" of looping it's point the line where it stoped.
 
that line is more like function called "value=(x)" x used as integer. but that is not the problem probably. its like a mountain

original command
then it calls a command that calls another command that calls another command that calls another command ...ZzzZ... gets to 100 something then boom stack error on next command. usually only happens in loop but loop can include other commands

good way to check is put a "p" something in section. then u can see if its being ran over and over before crash
 

Zeriab

Sponsor

It is definitely NOT because of a loop.
The reason is that the call stack becomes too large.
Whenever you call a method you put it on the call stack. When it's done you remove it and go back the previous method.
It sounds like you were slowing adding methods on the stack without removing them until finally you at an apparently random place crossed the limit of the stack.

An example of it happening could be something like this:
[rgss]def scene_a
  # Do loads of stuff
  scene_b
end
 
def scene_b
  # Do loads of stuff
  scene_a
end
[/rgss]
When you are done with scene_a you call scene_b and vice-versa. This way you'll slowly build up the call stack and of course you will most likely NOT cross the limit with the scene_a or scene_b method call.

*hugs*
- Zeriab
 

Atoa

Member

there was an method
Code:
 

def atb=(x)

  return @atb = x

end
on game actor

and this was part of the method thar caused the error:
Code:
for actor in $game_party.actors

  actor.atb = 0 unles actor.dead?

end

it was the atb script, i wanted to reset all atb when the escape fails.
Changing it to "@active_battler.atb = 0" solved the problem.

But i still don't why it happens O.o
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top