Search Unity

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

Discussion in 'Scripting' started by Chrisasan, May 29, 2016.

  1. Chrisasan

    Chrisasan

    Joined:
    Mar 27, 2015
    Posts:
    270
    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.)
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    ok, so don't have a Start() function on the object you are instantiating which instantiates copies of itself...
     
    lordofduct likes this.
  3. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,537
    What did you expect to happen?
     
    TaleOf4Gamers and Kiwasi like this.
  4. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
    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
     
  5. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
  7. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
    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.
     
    roojerry, gorbit99 and Kiwasi like this.
  8. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    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.
     
  9. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,537
    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?
     
  10. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
    I think ctrl-z whenever I make a mistake drawing or writing on paper...
     
  11. image28

    image28

    Joined:
    Jul 17, 2013
    Posts:
    457
  12. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Yes, you are :p
    I only found myself doing ctrl-z in chrome, but it works, so I'm not weird