Unity OnGUI crash

Hello!

My unity copy was crashing and freezing very often.
Digging to the very essence of the problem I found that OnGUI function is very fragile and many exceptions happening there lead to hang or crash of the editor.

Try this code:

using UnityEngine;
using System.Collections;
using System;

public class CrashMe : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	int [] qqq = null;
	void OnGUI()
	{
		try{
			qqq[1] += 10;
		}
		catch( Exception ex )
		{
			Debug.Log( ex.Message );
		}
	}
}

2.6.1 Pro gets crashed.
Yeah, in this sample the programmer’s mistake is obvious, but it take hours to track down something like this in a real game.

Plz, fix teh engine.

Plz, log teh bug!

Seriously, any time you have something like this posting it here in the forums isn’t the right way to go. Sure, it might help notify a few other developers (a good thing), but it doesn’t get it in the queue for us to look at and address. You can, and should, log bugs against issues like this and that can easily be done via the Help menu inside of Unity. That way it’s not left to hoping we scan past it here on the forums, instead it goes straight to our dev/QA teams for them to investigate and repair. So if you haven’t done so already please log this so (a) it’s in our bug tracking system, and (b) you become familiar with the bug logging tools in Unity.

Thanks and sorry about the snag!

Please, don’t get me wrong, but the experience of bug reporting in a “right way” is quite disappointing.

The editor crashes few times a day and the bug reporting window pops up, sometimes. Sometimes the main app just hangs without an option to report a bug. In a few days after reporting Nicolaj Schweitz replies by email that there is too little data to figure out what happened that time to my unity. I didn’t understand why it crashed that time, even less i do remember in a week.

Sometimes we get lucky and track down crashes to someting as simple and reproducible as exceptions in a custom thread or ongui function.

Thus the bug reporting turns of little use. I wish Unity could collect more data to avoid the “wut happnd that time?” letters (no offense, just letters from QA with instructions to “right way of bug reporting” with request for more details are as useful)

Unity can’t collect anything if the user made a “that stupid error” that the whole Mono 1.2.5 environment just blew up and thus took Unity with it.
Once Unity upgrades to mono 2.x that should hopefully become quite a bit better better.

A common way to kill the the whole mono environment including Unity instantly are for example errorous unmanaged code handlings. Debugging these things is defacto totally impossible, in such cases most resort to implement it within VC#, test it there and transfer the code once done, at least I do :blush:

As for the logging: you can start the bug reporter manually. so if it does not come up, just open it and report the bug manually. That always works :slight_smile:

Yes, and one can always write another report “unity crashed dunno why” :slight_smile: Nicolaj will be happy =)

But thanks for the hint, just found that a log from previous run can be found under the link “see which files are being sent to unity”. It contains a stack trace from last crash, that helps a lot.

If you open the console then editor log, you will find yourself in the log of the current session. but in the same folder (windows) / right above in the log tool of osx, you will find a prev log.
that will show you potentially what lead to the death

+1

And you might not know why it happened but your crash log and other information we automatically include just might provide the needed information to our dev/QA teams. Especially if there are a few reports on the same general issue. So even if you don’t get the automatic bug reporter to appear, please log crashes manually anyway. Thanks!