Search Unity

12p23 ECSTestsFixture Teardown Assert Fail

Discussion in 'Entity Component System' started by tertle, Jan 19, 2019.

  1. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    -edit- check post 2, found an actual assertion failure.

    All my tests were passing in 12p21, but now if I run them I get an internal error from ComponentGroup randomly. These tests inherit from ECSTestsFixture though I don't think that has anything to do with it.

    This isn't on a specific test, it just randomly fails a tests with this error. Four runs of the same tests in a row, the third one actually passed.

    upload_2019-1-20_9-7-2.png

    upload_2019-1-20_9-7-8.png

    upload_2019-1-20_9-7-19.png

    upload_2019-1-20_9-7-37.png

    During this test, the error was printed 6 times (6 failures).

    No other exceptions or errors are thrown. Looking at source I do not understand how this specific NativeArray is not being disposed as as far as I can tell, the 3 times it's created it's destroyed very quickly after.

    If i revert to 12p21 they all pass consistently.

    Not all my tests seem to be affected by the failures, but I can't see anything in particular that would cause this set of tests to start failing now. The tests don't seem like they're failing because of the above error, but instead failing because entities are somehow persisting between tests causing unexpected results.
     
    Last edited: Jan 19, 2019
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    I've noticed a new error during the teardown, this wasn't printed in actual unity console only in the test so I missed it. The actual failure is happening during the teardown of ECSTestsFixture.

    Code (csharp):
    1.  
    2. ---
    3. System.NullReferenceException : Object reference not set to an instance of an object
    4. TearDown : UnityEngine.Assertions.AssertionException : Assertion failure. Values are not equal.
    5. Expected: 3 == 2
    6. ---
    7. at Unity.Entities.EntityDataManager.RequiresBuildingResidueSharedComponentIndices (Unity.Entities.Archetype* srcArchetype, Unity.Entities.Archetype* dstArchetype) [0x00001] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\EntityDataManager.cs:1529
    8.   at Unity.Entities.EntityDataManager.RemoveEntitiesInChunkWithSystemState (Unity.Entities.Chunk* chunk, Unity.Entities.ArchetypeManager archetypeManager, Unity.Entities.SharedComponentDataManager sharedComponentDataManager) [0x00016] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\EntityDataManager.cs:1133
    9.   at Unity.Entities.EntityDataManager.DeleteChunks (Unity.Collections.NativeArray`1[T] chunks, Unity.Entities.EntityDataManager* manager, Unity.Entities.ArchetypeManager archetypeManager, Unity.Entities.SharedComponentDataManager sharedComponentDataManager) [0x0021a] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\EntityDataManager.cs:1117
    10.   at Unity.Entities.EntityManager.DestroyEntity (Unity.Entities.ComponentGroup componentGroupFilter) [0x00030] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\EntityManager.cs:391
    11.   at BovineLabs.Testing.Systems.Inventory.InventorySystemTests.UpdateInventorySystemDestroyEvents (BovineLabs.Systems.Inventory.InventorySystem inventorySystem) [0x00025] in D:\Documents\BovineLabs\Shattered.Game\Assets\Testing\Systems\Inventory\InventorySystemTests.cs:181
    12.   at BovineLabs.Testing.Systems.Inventory.InventorySystemTests.AddItemToInventory () [0x0005d] in D:\Documents\BovineLabs\Shattered.Game\Assets\Testing\Systems\Inventory\InventorySystemTests.cs:36
    13.   at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
    14.   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <ac823e2bb42b41bda67924a45a0173c3>:0
    15. --TearDown
    16.   at UnityEngine.Assertions.Assert.Fail (System.String message, System.String userMessage) [0x0001f] in C:\buildslave\unity\build\Runtime\Export\Assertions\Assert\AssertBase.cs:26
    17.   at UnityEngine.Assertions.Assert.AreEqual[T] (T expected, T actual, System.String message, System.Collections.Generic.IEqualityComparer`1[T] comparer) [0x00061] in C:\buildslave\unity\build\Runtime\Export\Assertions\Assert\AssertGeneric.cs:31
    18.   at UnityEngine.Assertions.Assert.AreEqual[T] (T expected, T actual, System.String message) [0x00009] in C:\buildslave\unity\build\Runtime\Export\Assertions\Assert\AssertGeneric.cs:19
    19.   at UnityEngine.Assertions.Assert.AreEqual (System.Int32 expected, System.Int32 actual) [0x0000b] in C:\buildslave\unity\build\Runtime\Export\Assertions\Assert\AssertPrimitiveTypes.cs:176
    20.   at Unity.Assertions.Assert.AreEqual (System.Int32 expected, System.Int32 actual) [0x0000b] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\Stubs\Unity.Assertions\Assert.cs:81
    21.   at Unity.Entities.EntityManager+EntityManagerDebug.CheckInternalConsistency () [0x00023] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\EntityManager.cs:1479
    22.   at Unity.Entities.Tests.ECSTestsFixture.TearDown () [0x00040] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities.Tests\ECSTestsFixture.cs:67
    23.   at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
    24.   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <ac823e2bb42b41bda67924a45a0173c3>:0
    25. ---
    26.  
    Different test, similar assert.

    Code (CSharp):
    1. AddTwoPerFrame (0.031s)
    2. ---
    3. System.NullReferenceException : Object reference not set to an instance of an object
    4. TearDown : UnityEngine.Assertions.AssertionException : Assertion failure. Values are not equal.
    5. Expected: 5 == 3
    6. ---
    7. at Unity.Entities.EntityDataManager.RequiresBuildingResidueSharedComponentIndices (Unity.Entities.Archetype* srcArchetype, Unity.Entities.Archetype* dstArchetype) [0x00001] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\EntityDataManager.cs:1529
    8.   at Unity.Entities.EntityDataManager.RemoveEntitiesInChunkWithSystemState (Unity.Entities.Chunk* chunk, Unity.Entities.ArchetypeManager archetypeManager, Unity.Entities.SharedComponentDataManager sharedComponentDataManager) [0x00016] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\EntityDataManager.cs:1133
    9.   at Unity.Entities.EntityDataManager.DeleteChunks (Unity.Collections.NativeArray`1[T] chunks, Unity.Entities.EntityDataManager* manager, Unity.Entities.ArchetypeManager archetypeManager, Unity.Entities.SharedComponentDataManager sharedComponentDataManager) [0x0021a] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\EntityDataManager.cs:1117
    10.   at Unity.Entities.EntityManager.DestroyEntity (Unity.Entities.ComponentGroup componentGroupFilter) [0x00030] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\EntityManager.cs:391
    11.   at BovineLabs.Testing.Systems.Inventory.InventorySystemTests.UpdateInventorySystemDestroyEvents (BovineLabs.Systems.Inventory.InventorySystem inventorySystem) [0x00025] in D:\Documents\BovineLabs\Shattered.Game\Assets\Testing\Systems\Inventory\InventorySystemTests.cs:181
    12.   at BovineLabs.Testing.Systems.Inventory.InventorySystemTests.AddTwoPerFrame () [0x0005e] in D:\Documents\BovineLabs\Shattered.Game\Assets\Testing\Systems\Inventory\InventorySystemTests.cs:60
    13.   at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
    14.   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <ac823e2bb42b41bda67924a45a0173c3>:0
    15. --TearDown
    16.   at UnityEngine.Assertions.Assert.Fail (System.String message, System.String userMessage) [0x0001f] in C:\buildslave\unity\build\Runtime\Export\Assertions\Assert\AssertBase.cs:26
    17.   at UnityEngine.Assertions.Assert.AreEqual[T] (T expected, T actual, System.String message, System.Collections.Generic.IEqualityComparer`1[T] comparer) [0x00061] in C:\buildslave\unity\build\Runtime\Export\Assertions\Assert\AssertGeneric.cs:31
    18.   at UnityEngine.Assertions.Assert.AreEqual[T] (T expected, T actual, System.String message) [0x00009] in C:\buildslave\unity\build\Runtime\Export\Assertions\Assert\AssertGeneric.cs:19
    19.   at UnityEngine.Assertions.Assert.AreEqual (System.Int32 expected, System.Int32 actual) [0x0000b] in C:\buildslave\unity\build\Runtime\Export\Assertions\Assert\AssertPrimitiveTypes.cs:176
    20.   at Unity.Assertions.Assert.AreEqual (System.Int32 expected, System.Int32 actual) [0x0000b] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\Stubs\Unity.Assertions\Assert.cs:81
    21.   at Unity.Entities.EntityManager+EntityManagerDebug.CheckInternalConsistency () [0x00023] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities\EntityManager.cs:1479
    22.   at Unity.Entities.Tests.ECSTestsFixture.TearDown () [0x00040] in D:\Documents\BovineLabs\Shattered.Game\Library\PackageCache\com.unity.entities@0.0.12-preview.23\Unity.Entities.Tests\ECSTestsFixture.cs:67
    23.   at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
    24.   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <ac823e2bb42b41bda67924a45a0173c3>:0
    25. ---
    26. AddTwoPerFrame: 0
    I think from reading the stack the failure happens in TearDown on this call
    m_ManagerDebug.CheckInternalConsistency();
    Which from diffing packages, was added in p22

    Which fails on this assert
    Assert.AreEqual(entityCountEntityData, entityCountArchetypeManager);
     
    Last edited: Jan 19, 2019
  3. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Could you extract out a test that triggers this error?

    If this assert triggers it means there is some internal corruption in the EntityManager.
     
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    I'm in the process of moving houses but I'll try submit a bug report with a test tomorrowish~
     
  5. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    Reported: 1120592
     
    Antypodish likes this.