Jump to content
Sign in to follow this  
  • entries
  • comments
  • views

Infinite loops == BAD

Sign in to follow this  


Infinite loops result in some truly unpredicatble behavior. Especially when the infinite loops exists in a script rather than in code.

Basically I had a function (I'll call it FunctionA) that worked something like this...

while ( conditionA is false )
pause execution here

if we got here, then call FunctionB

then in FunctionB I had

while ( conditionA is true )
pause execution here

if we got here, then call FunctionA

So, this worked nice and didn't cause any problems... that is until a different bug somewhere else caused the object that was being tested for conditionA to be NULL.... so now, the while test would be undefined, and the scripts behavior in this case is to keep executing... that's where all hell broke loose and eventually resulted in a stack overflow.

It's a silly mistake, I should've thought about this problem a little longer before I implemented such a bad solution. Oh well, I refactored that piece of code and I'm about to test it.

Sign in to follow this  


Recommended Comments

There are no comments to display.

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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!