Search Unity

How can I find where this exception is coming from?

Discussion in 'Entity Component System' started by LukePammant, Apr 5, 2019.

  1. LukePammant

    LukePammant

    Joined:
    Mar 10, 2015
    Posts:
    50
    I'm getting the following exception after upgrading my entities package but I don't see any indication as to what file/code is even throwing the exception.

    Code (CSharp):
    1.  
    2. InvalidOperationException: The NativeArray has been deallocated, it is not allowed to access it
    3. Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) <0x1c990ff8d10 + 0x00052> in <8ff0542c1b944876840eea6545879d3f>:0
    4. Unity.Collections.NativeArray`1[T].CheckElementReadAccess (System.Int32 index) (at C:/buildslave/unity/build/Runtime/Export/NativeArray/NativeArray.cs:117)
    5. Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at C:/buildslave/unity/build/Runtime/Export/NativeArray/NativeArray.cs:138)
    6. BuildChildArraySystem.OnUpdate (Unity.Jobs.JobHandle inputDeps) (at Assets/Scripts/ECS/Systems/TargetHandlers/BuildChildArraySystem.cs:50)
    7. Unity.Entities.JobComponentSystem.InternalUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.29/Unity.Entities/ComponentSystem.cs:635)
    8. Unity.Entities.ScriptBehaviourManager.Update () (at Library/PackageCache/com.unity.entities@0.0.12-preview.29/Unity.Entities/ScriptBehaviourManager.cs:97)
    9. Unity.Entities.ComponentSystemGroup.OnUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.29/Unity.Entities/ComponentSystemGroup.cs:361)
    10. UnityEngine.Debug:LogException(Exception)
    11. Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.0.12-preview.29/Unity.Entities/Stubs/Unity/Debug.cs:25)
    12. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.29/Unity.Entities/ComponentSystemGroup.cs:365)
    13. Unity.Entities.ComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.29/Unity.Entities/ComponentSystem.cs:502)
    14. Unity.Entities.ScriptBehaviourManager:Update() (at Library/PackageCache/com.unity.entities@0.0.12-preview.29/Unity.Entities/ScriptBehaviourManager.cs:97)
    15. Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.29/Unity.Entities/ScriptBehaviourUpdateOrder.cs:129)
    16.  
    also:
    Code (csharp):
    1.  
    2. A Native Collection has not been disposed, resulting in a memory leak. Allocated from:
    3. Unity.Collections.NativeArray`1:.ctor(Int32, Allocator, NativeArrayOptions) (at C:\buildslave\unity\build\Runtime\Export\NativeArray\NativeArray.cs:43)
    4. Unity.Entities.ComponentChunkIterator:CreateArchetypeChunkArray(MatchingArchetypeList, Allocator, JobHandle&, ComponentGroupFilter&, JobHandle) (at Library\PackageCache\com.unity.entities@0.0.12-preview.29\Unity.Entities\Iterators\ComponentChunkIterator.cs:191)
    5. Unity.Entities.ComponentGroup:CreateArchetypeChunkArray(Allocator) (at Library\PackageCache\com.unity.entities@0.0.12-preview.29\Unity.Entities\Iterators\ComponentGroup.cs:479)
    6. BuildChildArraySystem:OnUpdate(JobHandle) (at Assets\Scripts\ECS\Systems\TargetHandlers\BuildChildArraySystem.cs:34)
    7. Unity.Entities.JobComponentSystem:InternalUpdate() (at Library\PackageCache\com.unity.entities@0.0.12-preview.29\Unity.Entities\ComponentSystem.cs:626)
    8. Unity.Entities.ScriptBehaviourManager:Update() (at Library\PackageCache\com.unity.entities@0.0.12-preview.29\Unity.Entities\ScriptBehaviourManager.cs:97)
    9. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library\PackageCache\com.unity.entities@0.0.12-preview.29\Unity.Entities\ComponentSystemGroup.cs:361)
    10. Unity.Entities.ComponentSystem:InternalUpdate() (at Library\PackageCache\com.unity.entities@0.0.12-preview.29\Unity.Entities\ComponentSystem.cs:502)
    11. Unity.Entities.ScriptBehaviourManager:Update() (at Library\PackageCache\com.unity.entities@0.0.12-preview.29\Unity.Entities\ScriptBehaviourManager.cs:97)
    12. Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library\PackageCache\com.unity.entities@0.0.12-preview.29\Unity.Entities\ScriptBehaviourUpdateOrder.cs:129)
    13.  
    The two exceptions seem to contradict each other?

    Is there an option I can set somewhere that would help me get to the root of the problem?
     
    Last edited: Apr 6, 2019
  2. LukePammant

    LukePammant

    Joined:
    Mar 10, 2015
    Posts:
    50
    FWIW I managed to find the troublesome system because it's run time is >100ms when the exception is thrown.
    upload_2019-4-6_13-47-41.png