- Home /
Unity freezes with deadlocks.
We are working with a project in unity, and are having some problems with dead locks, but we have no way to debug it, i tried to start another thread to access the stack trace of the unity's thread after it freezes, but in this version of mono the stack trace methods are not implemented. I tried several debug programs like windbg, but all these programs just get stack trace of the proccess system calls. Any sugestions on some way to debug this? There's some way of get the current unity's thread stacktrace after it freezes??
is it really a deadlock? (i.e. two threads waiting on locks that the other is respectively holding) or is it just that you've accidentally created a tight infinite loop?
it's not an infinite loop, the process stay with 0% of processor use.
What makes you think this is a deadlock? are you talking about a deadlock in your own code, or a deadlock in Unity's code? Can you be more specific on exactly what you are doing, and what the exact results are you are seeing, and how those differ from what you expect. thnx
Why are stack trace methods not implemented in this version of mono? In what version of mono? They should always work in the mono implementation, which runs in the Unity editor.
You can get a stack trace with System.Environment.StackTrace -- this doesn't really help on the freeze itself, but might help in tracking it down.
Answer by Dreamora · May 24, 2010 at 01:29 AM
When it freezes it has commonly not crashed so you don't get stack traces.
Once it crashes though it will write the according stack trace to the log file (in the editor to the current one, once you reopen the editor it will be renamed to become the -prev one)
Without knowing what you are doing in general its hard to impossible to offer suggestions on what might be the cause as there are quite a few possibilities. As you added the concurrency tag you should potentially be warned that threads in Mono 1.2.5 aren't that stable and also its important to keep in mind that Unity 2 is not threadsafe so if you have any threading in there ensure to not touch anything create thats not part of System (including the "Object" class which unless specified differently, normally is UnityEngine.Object)
Debugging i discovered that the problem occurs inside the Instantiate method, specially when instantiating a lot of gameobjects in a row (not that many, around 10 objects). Any sugestions? i am out of ideas here.
without seeing the code i don't think guessing will help - instantiating doesn't deadlock if it's done synchronously
Your answer
![](https://koobas.hobune.stream/wayback/20220613012755im_/https://answers.unity.com/themes/thub/images/avi.jpg)