My DOTS code crashes Unity. How do I debug?

I am writing some code for my camera and somewhere in my math involving quaternions (I think) sometimes whatever happens completely crashes Unity. I tried attaching Visual Studio (for Mac) by clicking the “Play” button in Visual Studio, but it immediately stops the attachment once Unity dies, stopping debugging. The crash report Mac provides about Unity is also useless, as the detail for the crashed thread is only about DOTS jobs, not the exact line of code I wrote.

My DOTS code is running without Burst and in the main thread (.WithoutBurst().Run()), so I was thinking the crash report would provide more detail about my code.

How would I go about debugging DOTS code that crashes Unity?

While I can only suggest to proceed by elimination, commenting lines of code that are suspect, I can share an experience where my code was crashing unity.

The case I faced was when using native stream, my code was trying to read from a native stream that was not created.
This resulted in an invalid acces to memory and crashed unity.

1 Like

Check out the Editor.log file. When unity crashes it translate the callstack including C# JIT code to symbols. When burst is still enabled, make sure to enable burst debug mode in the Jobs->Burst menu

How to read this callstack? It’s not really readable

My solution usually was to step through until I figured out where it crashed. Time consuming but if the stack trace does not tell you where it happens, you will have to navigate there.

For me burst code that crashes never translates to actual symbols. The closest it gets is AbortShim: operator= and Ordinal10.
But that doesn’t matter that much since all the interesting stuff is still inside the dmp file which you can just step through with a native debugger. Just make sure to include the burst generated pdb file in the symbol paths of your debugger if it isn’t resolved automatically for you.

1 Like