How to debug a stack overflow exception?

3

I am working on a game, and everything was fine, until I added some features. I worked for about one month on this features, and unfortunately I wasn't wise enough to test smaller parts of the code, so I have added many codes, and now I get this error.

Unhandled exception at 0x77555098 (ntdll.dll) in SFML setup.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x006D2FA8). 

my code is large, and it will be really hard, to check every single function. In the debugger call stack this specific function is repeated many many times.

void SceneNode::onCommand(const Command &command, sf::Time dt)
{
   if (command.category.at(getCategory()))
      command.action(*this, dt);

   for(const Ptr& child : mChild)
   {
      child->onCommand(command, dt);
   }
}

SceneNode is tree structure, and has some child. this function try to iterate through the tree, to see which nodes can take a specific command.

c++
debugging
stack-overflow
asked on Stack Overflow Oct 31, 2016 by shayan

1 Answer

0

I answer to the question: "How to debug a stack overflow exception?".
1- Bug reproducible? if yes go ahead
2- Attach/open your process with windbg (or ollydbg or any other)
3- Trigger your exception
4- See the content of register (particularly (for 32 bit) eip, ebp)
5- dump esp in order to examine the stack frame
It should be like:

{ Local Var -> Saved EBP -> Saved EIP -> Params -> Address of Exception Handler }

You can find a really good and detailed explanation at this link

answered on Stack Overflow Oct 31, 2016 by invictus1306

User contributions licensed under CC BY-SA 3.0