Critical Bug! Infinite Instantiate, no way to stop player.

I was building a prototype for a video game and wanted unity to instantiate a tiled set of objects.
The problem!
The obj Instantiate 100 of it self. Each object that is being instantiate Instantiates 100 objects of itself.
This causes and endless loop in the Start() function.

While unity is in the Start() functions the player cannot be stopped. (I lost my work as the scene was not saved.)

ok, so don’t have a Start() function on the object you are instantiating which instantiates copies of itself…

1 Like

What did you expect to happen?

2 Likes

You reinvented the Fork Bomb.

Pretty much, it is impossible for the compiler to always tell ahead of time what is an infinite loop and what is not. Also, there are cases where we actually do want something to loop infinitely, or as long as the program is running.

You’ll run into freezes from infinite loops a lot. =p

This is so common that Unity recently had an article about how to break out of infinite loops.

That’s some crazy stuff. Currently debating if the cure is worse then the disease.

I’ll stick to my save and commit often method for now.

Ya, I hit Ctrl-S so often I find myself trying to save web pages in Chrome.

The nice thing about that blog post is if you don’t know where the infinite loop is happening, then using a debugger can offer some hints as to what’s going on.

3 Likes

I save every time i put at least 2 characters in a code, so much so, that i started doing it in visual studio, even after and before compiles which saves by itself, so triple save
Dont worry, if you go with the old schooled ctrl-alt-del, then you can force a program to stop in the processes tab (i thibj thats it in english) or yoh could wait for the blue screen of death, where your computer can look at you and ask “why have you done this to me?!” before completely shutting off.

have you ever been reading a book and found yourself doing a ‘ctrl+f’, or while writing in a notebook doing a ‘ctrl+s’ with your left hand reflexively?

Or am I just the only weird one?

I think ctrl-z whenever I make a mistake drawing or writing on paper…

We use a script to save the scene every time you hit play… hasn’t been updated to unity 5.3’s SceneManger system yet but still works. The editor script we use can be found here Auto save every five minutes? - Questions & Answers - Unity Discussions

Yes, you are :stuck_out_tongue:
I only found myself doing ctrl-z in chrome, but it works, so I’m not weird