Potential Bug: Crash when loading Additive Scene

Hi Aron,

Wasn’t sure if you had a specific place to post bugs, but I wanted to at least bring this issue to your attention.

Unity version: 2017.3.0f3
A* version: Currently 4.1.9 free.

I recently changed the way that I manage my scenes (some are now additive) and afterwards Unity began to crash intermittently.

I took a look at the Unity editor log and was able to zero in on the issue. If you take a look at the stack trace i’ve included below, the issue occurs while drawing the Gizmos, particularly inside RetainedGizmos.SubmitLines() when attempting to release the ListPools at the bottom.

ListPool.Release() seems to cause the crash when list is set to null.

public static void Release (ref List<T> list) {
    Release(list);
    list = null;
}

Commenting out “list = null” stops the crashing. The call to release above that line is re-adding the list to the pool, so I’m assuming setting that list to null is making it angry.

EDIT: I should add that I currently have A* set to using 1 thread.
EDIT 2: Unfortunately it seems to have crashed again in the same area (ListPool line 166). I’m going to have to just delay when the AStar behaviour is enabled or try disabling AI threads for now until I can take another look at it.

========== OUTPUTING STACK TRACE ==================

0x00007FFA160FC6BA (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\class.c:4887] mono_class_init 
0x00007FFA160F5BC2 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\class.c:2945] collect_implemented_interfaces_aux 
0x00007FFA1610158F (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\class.c:4095] mono_class_setup_vtable_general 
0x00007FFA161014AE (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\class.c:3630] mono_class_setup_vtable_full 
0x00007FFA160FB7BB (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\class.c:2540] mono_class_get_vtable_entry 
0x00007FFA15FA2779 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini-trampolines.c:903] mono_vcall_trampoline 
  ERROR: SymGetSymFromAddr64, GetLastError: 'The specified module could not be found.' (Address: 00000000132E1838)
  ERROR: SymGetModuleInfo64, GetLastError: 'A dynamic link library (DLL) initialization routine failed.' (Address: 00000000132E1838)
0x00000000132E1838 ((<unknown>)) (function-name not available)
0x000000003F891AE3 (Mono JIT Code) System.Collections.Generic.List`1<T_REF>:Add (T_REF)
0x0000000042A9E845 (Mono JIT Code) [...\Assets\ThirdParty\AstarPathfindingProject\Core\Misc\ListPool.cs:166] Pathfinding.Util.ListPool`1<UnityEngine.Vector3>:Release (System.Collections.Generic.List`1<UnityEngine.Vector3>) 
0x0000000042A9E311 (Mono JIT Code) [...\ThirdParty\AstarPathfindingProject\Core\Misc\ListPool.cs:138] Pathfinding.Util.ListPool`1<UnityEngine.Vector3>:Release (System.Collections.Generic.List`1<UnityEngine.Vector3>&) 
0x0000000042A9A3C3 (Mono JIT Code) [...\ThirdParty\AstarPathfindingProject\Utilities\RetainedGizmos.cs:211] Pathfinding.Util.RetainedGizmos/Builder:SubmitLines (Pathfinding.Util.RetainedGizmos,ulong) 
0x0000000042A98C0E (Mono JIT Code) [...\Assets\ThirdParty\AstarPathfindingProject\Utilities\RetainedGizmos.cs:128] Pathfinding.Util.RetainedGizmos/Builder:Submit (Pathfinding.Util.RetainedGizmos,Pathfinding.Util.RetainedGizmos/Hasher) 
0x0000000042A98992 (Mono JIT Code) [...\Assets\ThirdParty\AstarPathfindingProject\Utilities\GraphGizmoHelper.cs:150] Pathfinding.Util.GraphGizmoHelper:Submit () 
0x0000000042A987AB (Mono JIT Code) [...\Assets\ThirdParty\AstarPathfindingProject\Utilities\GraphGizmoHelper.cs:156] Pathfinding.Util.GraphGizmoHelper:System.IDisposable.Dispose () 
0x0000000042A912DD (Mono JIT Code) [...\Assets\ThirdParty\AstarPathfindingProject\Generators\GridGenerator.cs:1366] Pathfinding.GridGraph:OnDrawGizmos (Pathfinding.Util.RetainedGizmos,bool) 
0x0000000042A8DF60 (Mono JIT Code) [...\Assets\ThirdParty\AstarPathfindingProject\Core\AstarPath.cs:704] AstarPath:OnDrawGizmos () 
0x000000003F8A3354 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FFA15F0437A (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini-runtime.c:2620] mono_jit_runtime_invoke 
0x00007FFA16108E87 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2853] do_runtime_invoke 
0x00007FFA1611188F (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2905] mono_runtime_invoke 
0x0000000140A2EAEC (Unity) scripting_method_invoke
0x0000000140A2243A (Unity) ScriptingInvocation::Invoke
0x0000000140A234AE (Unity) ScriptingInvocation::InvokeChecked
0x00000001409E4BB1 (Unity) MonoBehaviour::CallMethodInactive
0x0000000140C2CED9 (Unity) DrawMonoGizmo
0x0000000140C310D2 (Unity) GizmoManager::DrawAllGizmos
0x0000000140CCC7F9 (Unity) Camera::FinishRenderingEditorCamera
0x000000003F23AD17 (Mono JIT Code) (wrapper managed-to-native) UnityEditor.Handles:Internal_FinishDrawingCamera (UnityEngine.Camera,bool)
0x000000003F23ABF5 (Mono JIT Code) [C:\buildslave\unity\build\artifacts\generated\common\editor\EditorHandlesBindings.gen.cs:353] UnityEditor.Handles:Internal_FinishDrawingCamera (UnityEngine.Camera) 
0x000000003E0FE5BC (Mono JIT Code) [C:\buildslave\unity\build\artifacts\generated\common\editor\EditorHandlesBindings.gen.cs:963] UnityEditor.Handles:DrawCameraStep2 (UnityEngine.Camera,UnityEditor.DrawCameraMode) 
0x000000003E0D7E02 (Mono JIT Code) [C:\buildslave\unity\build\Editor\Mono\SceneView\SceneView.cs:1661] UnityEditor.SceneView:OnGUI () 
0x000000003F892E85 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FFA15F0437A (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini-runtime.c:2620] mono_jit_runtime_invoke 
0x00007FFA16108E87 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2853] do_runtime_invoke 
0x00007FFA16111AA2 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:3012] mono_runtime_invoke_checked 
0x00007FFA16112217 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:5116] mono_runtime_try_invoke_array 
0x00007FFA16111A1E (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:4996] mono_runtime_invoke_array_checked 
0x00007FFA160EAD34 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\icall.c:3286] ves_icall_InternalInvoke 
0x000000003E0AA891 (Mono JIT Code) (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
0x000000003E0A9365 (Mono JIT Code) System.Reflection.MonoMethod:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo)
0x000000003E0A903F (Mono JIT Code) System.Reflection.MethodBase:Invoke (object,object[])
0x000000003AA8B2BB (Mono JIT Code) [C:\buildslave\unity\build\Editor\Mono\HostView.cs:295] UnityEditor.HostView:Invoke (string,object) 
0x000000003AA8B110 (Mono JIT Code) [C:\buildslave\unity\build\Editor\Mono\HostView.cs:289] UnityEditor.HostView:Invoke (string) 
0x000000003C8B7C39 (Mono JIT Code) [C:\buildslave\unity\build\Editor\Mono\HostView.cs:256] UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect) 
0x000000003C885A00 (Mono JIT Code) [C:\buildslave\unity\build\Editor\Mono\GUI\DockArea.cs:388] UnityEditor.DockArea:OldOnGUI () 
0x000000003C870B99 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\UIElements\Managed\IMGUIContainer.cs:179] UnityEngine.Experimental.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event) 
0x000000003C53E2C8 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\UIElements\Managed\IMGUIContainer.cs:335] UnityEngine.Experimental.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event) 
0x0000000042CDB59C (Mono JIT Code) [C:\buildslave\unity\build\Runtime\UIElements\Managed\IMGUIContainer.cs:68] UnityEngine.Experimental.UIElements.IMGUIContainer:DoRepaint (UnityEngine.IStylePainter) 
0x0000000042CD5070 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\UIElements\Managed\Panel.cs:533] UnityEngine.Experimental.UIElements.Panel:PaintSubTree (UnityEngine.Event,UnityEngine.Experimental.UIElements.VisualElement,UnityEngine.Matrix4x4,UnityEngine.Rect) 
0x0000000042CDB1E8 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\UIElements\Managed\Panel.cs:549] UnityEngine.Experimental.UIElements.Panel:PaintSubTreeChildren (UnityEngine.Event,UnityEngine.Experimental.UIElements.VisualElement,UnityEngine.Matrix4x4,UnityEngine.Rect) 
0x0000000042CD52C5 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\UIElements\Managed\Panel.cs:537] UnityEngine.Experimental.UIElements.Panel:PaintSubTree (UnityEngine.Event,UnityEngine.Experimental.UIElements.VisualElement,UnityEngine.Matrix4x4,UnityEngine.Rect) 
0x0000000042CD0506 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\UIElements\Managed\Panel.cs:567] UnityEngine.Experimental.UIElements.Panel:Repaint (UnityEngine.Event) 
0x000000003C528FC8 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\UIElements\Managed\UIElementsUtility.cs:241] UnityEngine.Experimental.UIElements.UIElementsUtility:DoDispatch (UnityEngine.Experimental.UIElements.BaseVisualElementPanel) 
0x000000003C528B57 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\UIElements\Managed\UIElementsUtility.cs:78] UnityEngine.Experimental.UIElements.UIElementsUtility:ProcessEvent (int,intptr) 
0x000000003C5284E4 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\IMGUI\Managed\GUIUtility.cs:175] UnityEngine.GUIUtility:ProcessEvent (int,intptr) 
0x000000003C5286FF (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_bool_int_intptr (object,intptr,intptr,intptr)
0x00007FFA15F0437A (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini-runtime.c:2620] mono_jit_runtime_invoke 
0x00007FFA16108E87 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2853] do_runtime_invoke 
0x00007FFA1611188F (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2905] mono_runtime_invoke 
0x0000000140A2EAEC (Unity) scripting_method_invoke
0x0000000140A2243A (Unity) ScriptingInvocation::Invoke
0x0000000140A234EA (Unity) ScriptingInvocation::Invoke<bool>
0x000000014028278E (Unity) IMGUIScriptingClasses::ProcessEvent
0x000000014112A2AF (Unity) GUIView::ProcessRetainedMode
0x00000001413F9748 (Unity) GUIView::OnInputEvent
0x000000014112A193 (Unity) GUIView::ProcessInputEvent
0x00000001413EDF66 (Unity) GUIView::DoPaint
0x00000001413F37B0 (Unity) GUIView::RepaintAll
0x00000001411DE3FB (Unity) PlayerLoopController::UpdateScene
0x00000001411DF7C8 (Unity) PlayerLoopController::UpdateSceneIfNeeded
0x00000001411E9BDD (Unity) Application::TickTimer
0x000000014140EB0F (Unity) MainMessageLoop
0x00000001414103B5 (Unity) WinMain
0x0000000141E643A8 (Unity) __tmainCRTStartup
0x00007FFA721A1FE4 (KERNEL32) BaseThreadInitThunk
0x00007FFA73A4EF91 (ntdll) RtlUserThreadStart

========== END OF STACKTRACE ===========

Hi
This looks like a bug in the Mono JIT, not in this package. I think you should send a bug report to Unity with this information and if you can, a test scene which allows them to reproduce the crash.
If removing the “list = null” line works around the issue, then by all means do that. That line only exists to remove some potential bugs when not using the API correctly, however I don’t think it should be strictly necessary anywhere where this API is used.

I agree; As I mentioned in my update, commenting out the null didn’t help after all. I’ve sent Unity 2 crash reports last night. I’ll let you know if they get back to me with any useful information.
For now delaying the load of the AStar behavior has fixed the issue for me. I plan to change how I load my enemies and AI anyways as this is just a test scene.

Thanks for the reply!

1 Like