Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Unity Editor Crash -

Discussion in 'Scripting' started by clbartlett, Oct 10, 2023.

  1. clbartlett

    clbartlett

    Joined:
    May 10, 2022
    Posts:
    8
    Has anyone run into a Editor crash looking like this:

    Unhandled Exception:
    System.NullReferenceException: Object reference not set to an instance of an object
    at (wrapper stelemref) System.Object.virt_stelemref_sealed_class(intptr,object)
    at System.IO.Path.CanonicalizePath (System.String path) [0x000d6] in <787acc3c9a4c471ba7d971300105af24>:0
    at System.IO.Path.InsecureGetFullPath (System.String path) [0x001db] in <787acc3c9a4c471ba7d971300105af24>:0
    at System.IO.Path.GetFullPath (System.String path) [0x00000] in <787acc3c9a4c471ba7d971300105af24>:0
    at System.IO.Path.GetRelativePath (System.String relativeTo, System.String path, System.StringComparison comparisonType) [0x00033] in <787acc3c9a4c471ba7d971300105af24>:0
    at System.IO.Path.GetRelativePath (System.String relativeTo, System.String path) [0x00007] in <787acc3c9a4c471ba7d971300105af24>:0
    at System.IO.DefaultWatcher.IterateAndModifyFilesData (System.IO.DefaultWatcherData data, System.String directory, System.Boolean dispatch, System.String[] files) [0x001e3] in <d054a9182977441aa432503a474315ba>:0
    at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, System.Boolean dispatch) [0x000a8] in <d054a9182977441aa432503a474315ba>:0
    at System.IO.DefaultWatcher.UpdateDataAndDispatch (System.IO.DefaultWatcherData data, System.Boolean dispatch) [0x00040] in <d054a9182977441aa432503a474315ba>:0
    at System.IO.DefaultWatcher.Monitor () [0x0007b] in <d054a9182977441aa432503a474315ba>:0
    at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in <787acc3c9a4c471ba7d971300105af24>:0
    at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <787acc3c9a4c471ba7d971300105af24>:0
    at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <787acc3c9a4c471ba7d971300105af24>:0
    at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in <787acc3c9a4c471ba7d971300105af24>:0
    at System.Threading.ThreadHelper.ThreadStart () [0x00008] in <787acc3c9a4c471ba7d971300105af24>:0



    I just migrated my project to 2022 from 19. For the most part it works but I am opening a large text file in a coroutine. Not really doing anything with it. But when the system gets back from processing that coroutine it throws any number of errors. This one seems to be the most common. It is different each time I run. Sometimes it the error looks like this:

    NullReferenceException: Object reference not set to an instance of an object
    at UnityEngine.UIElements.StyleVariable.GetHashCode () [0x00022] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.StyleVariableContext.Add (UnityEngine.UIElements.StyleVariable sv) [0x00001] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdaterTraversal.ProcessMatchedVariables (UnityEngine.UIElements.StyleSheet sheet, UnityEngine.UIElements.StyleRule rule) [0x00031] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdaterTraversal.ProcessMatchedRules (UnityEngine.UIElements.VisualElement element, System.Collections.Generic.List`1[T] matchingSelectors) [0x00147] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdaterTraversal.TraverseRecursive (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x0012d] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.StyleSheets.HierarchyTraversal.Recurse (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x00016] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdaterTraversal.TraverseRecursive (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x0029c] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.StyleSheets.HierarchyTraversal.Recurse (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x00016] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdaterTraversal.TraverseRecursive (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x0029c] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.StyleSheets.HierarchyTraversal.Recurse (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x00016] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdaterTraversal.TraverseRecursive (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x0029c] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.StyleSheets.HierarchyTraversal.Recurse (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x00016] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdaterTraversal.TraverseRecursive (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x0029c] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.StyleSheets.HierarchyTraversal.Recurse (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x00016] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdaterTraversal.TraverseRecursive (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x0029c] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.StyleSheets.HierarchyTraversal.Recurse (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x00016] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdaterTraversal.TraverseRecursive (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x0029c] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.StyleSheets.HierarchyTraversal.Recurse (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x00016] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdaterTraversal.TraverseRecursive (UnityEngine.UIElements.VisualElement element, System.Int32 depth) [0x0029c] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.StyleSheets.HierarchyTraversal.Traverse (UnityEngine.UIElements.VisualElement element) [0x00001] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdater.ApplyStyles () [0x0003f] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeStyleUpdater.Update () [0x00024] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) [0x0001e] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.Panel.UpdateForRepaint () [0x0000e] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) [0x00078] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) [0x00051] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) [0x0003d] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) [0x0001a] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) [0x00001] in <79c7b132c51745cbae03eebea8111c0e>:0
    at UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) [0x00010] in <69483bb8da2444acb7ff79facafdfbf3>:0



    Submitting a bug report and sending them project isn't really an option. This is not a game applications and is for government work...
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,054
    Since you migrated: close the editor and IDE, delete the Library folder, then see if the errors went away.
    If not, try further narrowing down the cause. You already seem to know the error is with a coroutine and a large file. Be sure NOT to show the file in the Inspector (for testing, or in general) nor should Unity serialize it, especially if by "large" you mean 10+ megabytes.

    Btw, unless the editor is unresponsive or closes, it's an exception (error) logged to the console and NOT a crash.
     
  3. clbartlett

    clbartlett

    Joined:
    May 10, 2022
    Posts:
    8
    This is actually crashing the editor... like boom, gone. Had to go to the log files to see these errors. I have cleaned up the library and went through all the normal migration process. Half the time it crashes a couple seconds after loading completes. Other times if doesn't crash until I stop playing. Random. The code didn't change between 2019 and 22. Other things of note, one of the included libraries uses Burst... I mention now as my last log file I found this:


    =================================================================
    Native Crash Reporting
    =================================================================
    Got a UNKNOWN while executing native code. This usually indicates
    a fatal error in the mono runtime or one of the native libraries
    used by your application.
    =================================================================

    =================================================================
    Managed Stacktrace:
    =================================================================
    at <unknown> <0xffffffff>
    at System.Array:ClearInternal <0x000d6>
    at System.Array:Clear <0x002e2>
    at System.Collections.Generic.HashSet`1:Clear <0x000f2>
    at zzzUnity.Burst.CodeGen.AssemblyLoader:UpdateCache <0x00bba>
    at CompilerThreadContext:PrepareAssemblyLoader <0x00552>
    at CompilerThreadContext:Compile <0x0145a>
    at CompilerThread:CompilerThreadLoop <0x00e12>
    at System.Threading.ThreadHelper:ThreadStart_Context <0x00131>
    at System.Threading.ExecutionContext:RunInternal <0x0061d>
    at System.Threading.ExecutionContext:Run <0x0008a>
    at System.Threading.ExecutionContext:Run <0x001e2>
    at System.Threading.ThreadHelper:ThreadStart <0x000aa>
    at System.Object:runtime_invoke_void__this__ <0x00337>
    =================================================================
    Crash!!!
    SymInit: Symbol-SearchPath:
    OS-Version: 10.0.0

     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,054
    For testing you could try disabling Burst.

    I've had one of those crashes recently too but the callstack was always GUI related. Apparently some issue with rendering close-to-zero floating point values with scientific notation in the Animator (parameters or blend tree). At least this helped me point out that I should not leave the Animator window open/visible.

    Oh and be sure to use the latest patch version of 2022.3.
     
  5. clbartlett

    clbartlett

    Joined:
    May 10, 2022
    Posts:
    8
    Ok... so our application is dealing with VERY large numbers (we have some floating point error because of it but generally make the app work). Your comment about scientific notation is mildly worrying.
    Were you able to fix it?
     
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,054
    I have not had it happen to me in the latest 2022.3 patch release so far. And it was about values in the -1 to +1 range.

    If by "large" you mean large numbers (6+ digits to the left) then float will have a lower decimal resolution. Same issue causes animations and transforms of game objects start mucking up past a couple thousand units away from origin.