Unity Editor crashes when pressing play (2017.2.0f3 64bit)
I have a tiny project that suddenly started making the Unity editor crash everytime I press play. It doesn't happen with other projects so I'm assuming there is something I have done that's causing this. Debugging the error gives me a message saying: "ntdll.pdb not loaded". Don't know what it means. Read somewhere, in a similar case, that someone thought it was due to a fauluty loop. However I don't have any loops... yet, except the usual Update() functions. I do however run the experimental scripting version (.NET 4.6 Equivalent) can that have anything to do with it? It did work earlier though.
Thanks for the help!
Hi! If you're getting a reliable crash, can you please file a bug report? Thanks!
Answer by Novidoux · Dec 03, 2017 at 10:56 AM
I managed to find that a stack overflow was crashing the editor. Changing back to the stable scripting version (not a long term solution) allowed me to see what was causing the problem. It was a faulty auto property that was the issue.
While auto properties can be written and used like this:
public int myProperty {get;set;}
and then use the "myProperty" as a variable.
What I had done was do this:
public int myProperty
{
get
{
return myProperty;
}
set
{
myProperty = myOtherProperty ^2;
}
}
First of all, i'm not an expert, but the set property should include "= value". What I wrote after the = should really have been put in the get property.
Secondly, if the get set properties are written like this they should really point to a separate variable like this:
public int MyProperty;
public int myProperty
{
get
{
return MyProperty;
}
set
{
MyProperty = value;
}
}
Please correct me if I'm wrong.
The stack overflow error shown in the stable scripting version should be shown in the new one as well. I'm hoping and suggesting that it should be a feaure before stable release.
It only crashes on $$anonymous$$ac, my colleges with the same code but on Windows had an error but were able to play without the crash. $$anonymous$$y problem was this recursive get as well, ces't la vie.
Answer by UsefulYdyot · Dec 05, 2021 at 06:16 PM
Just had the same issue. In my case it was a hastily introduced getter that had a wrong self reference in it.
private int someStuff;
public int SomeStuff { get => SomeStuff; }
of course it should be
public int SomeStuff { get => someStuff; }
So, maybe you produced some unintended infinite loop somewhere in the new code. Not neccessarily a property, but a recursive method call.
Actually, what you would expect from a debugger is some sort of timeout that after 5 seconds of execution or so, stops execution and hints out an error alltogether with a callstack. But Unity obviously just hangs up. Had this with ms visual studio. Can't say how other environments behave. And maybe I just missed some project setting.