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.

Bug Crashes in freeing native memory B10.

Discussion in '2020.1 Beta' started by snacktime, May 29, 2020.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    I'm seeing this all over ranging from my code to SRP and they all share this in common. Can't figure out what triggers it. Our main scene has a test mode where we can just play it and it doesn't trigger there. If I go through our network login that arrives at the exact same scene it triggers fairly reliably on existing playmode.

    I am using the latest collections which has some new memory management stuff so it could be a bug there that's corrupting memory.

    Code (csharp):
    1.  
    2. 0x00007FF6E27A2142 (Unity) block_locate_free
    3. 0x00007FF6E27A283C (Unity) tlsf_memalign
    4. 0x00007FF6DF74C44F (Unity) DynamicHeapAllocator::Allocate
    5. 0x00007FF6DF74150A (Unity) DualThreadAllocator<DynamicHeapAllocator>::Allocate
    6.  
    Edit: sorry it's not always free that does it. It's still the same at the top of the trace but I've had it hit in deallocate also. Unfortunately last one was a few stack traces ago.
     
  2. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ok here is one that crashes on free.

    Code (csharp):
    1.  
    2. 0x00007FF6DF74E5B9 (Unity) MemoryProfiler::GetAllocationRoot
    3. 0x00007FF6DFEF2B09 (Unity) MemoryProfiler::UnregisterAllocation
    4. 0x00007FF6DF72FD0B (Unity) MemoryManager::RegisterDeallocation
    5. 0x00007FF6DF72BFBB (Unity) MemoryManager::Deallocate
    6. 0x00007FF6DF73DE5A (Unity) free_alloc_internal
    7. 0x00007FF6E079A94D (Unity) UnsafeUtility::Free
    8. 0x00007FF6E06BF76D (Unity) UnsafeUtility_CUSTOM_Free
    9. 0x00000208548B897D (Mono JIT Code) (wrapper managed-to-native) Unity.Collections.LowLevel.Unsafe.UnsafeUtility:Free (void*,Unity.Collections.Allocator)
    10. 0x00000208548A5C53 (Mono JIT Code) [C:\Games\aigame\AiClient\Packages\com.unity.collections\Unity.Collections\AllocatorManager.cs:259] Unity.Collections.AllocatorManager:TryLegacy (Unity.Collections.AllocatorManager/Block&)
    11. 0x00000208548A5ABB (Mono JIT Code) [C:\Games\aigame\AiClient\Packages\com.unity.collections\Unity.Collections\AllocatorManager.cs:277] Unity.Collections.AllocatorManager:Try (Unity.Collections.AllocatorManager/Block&)
    12. 0x00000208548A60AB (Mono JIT Code) [C:\Games\aigame\AiClient\Packages\com.unity.collections\Unity.Collections\AllocatorManager.cs:50] Unity.Collections.AllocatorManager:Free (Unity.Collections.AllocatorManager/AllocatorHandle,void*,int,int,int)
    13. 0x00000208548A5FBB (Mono JIT Code) [C:\Games\aigame\AiClient\Packages\com.unity.collections\Unity.Collections\AllocatorManager.cs:57] Unity.Collections.AllocatorManager:Free (Unity.Collections.AllocatorManager/AllocatorHandle,void*)
    14. 0x00000208553BC88B (Mono JIT Code) [C:\Games\aigame\AiClient\Packages\com.unity.collections\Unity.Collections\UnsafeList.cs:180] Unity.Collections.LowLevel.Unsafe.UnsafeList:Dispose ()
    15. 0x00000208764CAEDB (Mono JIT Code) [C:\Games\aigame\AiClient\Packages\com.unity.collections\Unity.Collections\UnsafeList.cs:828] Unity.Collections.LowLevel.Unsafe.UnsafeList`1<AiGame.ResourceItems.ResourceItemGrid/ResourceGridAction>:Dispose ()
    16. 0x00000208764CAE6B (Mono JIT Code) [C:\Games\aigame\AiClient\Assets\AiGame\Packages\ResourceItems\ResourceItemGrid.cs:262] AiGame.ResourceItems.ResourceItemGrid:Dispose ()
    17. 0x00000208764CABC3 (Mono JIT Code) [C:\Games\aigame\AiClient\Assets\AiGame\Packages\ResourceItems\ResourceItemSystem.cs:102] AiGame.ResourceItems.ResourceItemSystem:OnDestroy ()
    18. 0x000002086F641C85 (Mono JIT Code) [C:\Games\aigame\AiClient\Library\PackageCache\com.unity.entities@0.11.0-preview.7\Unity.Entities\ComponentSystemBase.cs:506]
    19.  
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    Have you tried to start Unity.exe from the commandline and pass the
    -debugallocator
    argument to see if it reveals additional information?

    Unity.exe -debugallocator -projectPath "C:\Projects\MyProject"
     
  4. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Downgraded entities/collections to a couple versions back and crashes stopped. It was every other play mode on a specific flow before. Now it's a couple dozen and no crashes. Collections has been having changes in memory allocation logic so it just seems a likely culprit, it corrupting memory somehow.
     
  5. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    It eventually hit with older entities also. Downgraded to b9 good so far.