Search Unity

Bug Memory Demons Leaking. Where is StackTrace?

Discussion in 'Entity Component System' started by MustEat, Dec 21, 2022.

  1. MustEat

    MustEat

    Joined:
    Jul 15, 2018
    Posts:
    18
    After converting to ECS/Physics 1.0.0-prev-15 and clearing all errors I'm getting hard crashes every launch. Seems like memory leaks (getting warnings for memory leaks) but no stacktrace available. I did enable the debugging flags as instructed but can't find any detail on the trace. All I have is the editor log shows:

    unity AA_EnableHighDpiScaling must be set before QCoreApplication is created
     
    Last edited: Dec 21, 2022
  2. plu83

    plu83

    Unity Technologies

    Joined:
    Jul 17, 2020
    Posts:
    6
    Are you running on Mac silicon hardware? The error message is not specific to DOTS. There exists an Issue Tracker report for it here. That said, someone encountering the issue mentioned they had some script compilation errors, which once resolved, got them out of this situation. Does your editor log make note of any obvious errors beyond what you posted?
     
    Last edited: Dec 23, 2022
    MustEat likes this.
  3. MustEat

    MustEat

    Joined:
    Jul 15, 2018
    Posts:
    18
    To clarify, I can launch fine. There are no errors in the console since I converted all scripts. When I play my scene, even if touching no input and taking no action, I get a crash in the worst case or warnings that allocations are being deleted because they are more than 4 frames old in the best case. It appears to be a memory leak but the output only points me to the collections package. I enabled JobTempMemoryLeakValidation but still no detail specific to my scripts.

    Here is the first warning message contents:


    Internal: deleting an allocation that is older than its permitted lifetime of 4 frames (age = 7)
    UnityEngine.StackTraceUtility:ExtractStackTrace ()
    Unity.Collections.Memory/Unmanaged/Array:Resize (void*,long,long,Unity.Collections.AllocatorManager/AllocatorHandle,long,int) (at Library/PackageCache/com.unity.collections@2.1.0-pre.2/Unity.Collections/Memory.cs:89)
    Unity.Collections.Memory/Unmanaged/Array:Resize<byte> (byte*,long,long,Unity.Collections.AllocatorManager/AllocatorHandle) (at Library/PackageCache/com.unity.collections@2.1.0-pre.2/Unity.Collections/Memory.cs:96)
    Unity.Collections.Memory/Unmanaged:Free<byte> (byte*,Unity.Collections.AllocatorManager/AllocatorHandle) (at Library/PackageCache/com.unity.collections@2.1.0-pre.2/Unity.Collections/Memory.cs:41)
    Unity.Collections.LowLevel.Unsafe.UnsafeParallelHashMapData:DeallocateHashMap (Unity.Collections.LowLevel.Unsafe.UnsafeParallelHashMapData*,Unity.Collections.AllocatorManager/AllocatorHandle) (at Library/PackageCache/com.unity.collections@2.1.0-pre.2/Unity.Collections/UnsafeParallelHashMap.cs:204)
    Unity.Collections.LowLevel.Unsafe.UnsafeParallelHashMapDataDispose:Dispose () (at Library/PackageCache/com.unity.collections@2.1.0-pre.2/Unity.Collections/UnsafeParallelHashMap.cs:404)
    Unity.Collections.LowLevel.Unsafe.UnsafeParallelHashMapDataDisposeJob:Execute () (at Library/PackageCache/com.unity.collections@2.1.0-pre.2/Unity.Collections/UnsafeParallelHashMap.cs:415)
    Unity.Jobs.IJobExtensions/JobStruct`1<Unity.Collections.LowLevel.Unsafe.UnsafeParallelHashMapDataDisposeJob>:Execute (Unity.Collections.LowLevel.Unsafe.UnsafeParallelHashMapDataDisposeJob&,intptr,intptr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,int) (at /Users/bokken/build/output/unity/unity/Runtime/Jobs/Managed/IJob.cs:58)


    Here's an example of the error I get if the Editor crashes:


    Obtained 38 stack frames.

    #0 0x0000010e69fbd3 in DebugDidSyncFence_NoLock(JobFence const&)

    #1 0x0000010e69fe76 in DebugDidSyncFence(JobFence const&)

    #2 0x0000010e6ae39c in CompleteFenceInternal(JobFence&, WorkStealMode)

    #3 0x0000010e69e27f in CleanupAllJobReflectionData()

    #4 0x0000010e6ae1a9 in JobSystem::ShutdownJobThreads()

    #5 0x0000010f7756bc in Application::CoreShutdown()

    #6 0x0000010f77fab9 in Application::Terminate(bool)

    #7 0x00000110bea93e in -[EditorApplication applicationShouldTerminate:]

    #8 0x007ff82128cec3 in -[NSApplication _docController:shouldTerminate:]

    #9 0x007ff82128cd8c in __91-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke

    #10 0x007ff82128ca52 in -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]

    #11 0x007ff82128c5c1 in -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:]

    #12 0x007ff82128c1a3 in -[NSApplication _shouldTerminate]

    #13 0x007ff82127c90b in -[NSApplication terminate:]

    #14 0x00000110bebf42 in -[EditorApplication terminate:]

    #15 0x00000110be29d8 in EditorApplicationForwardingTarget::Execute(MenuItem const&)

    #16 0x0000010f54e284 in MenuController::ExecuteMenuItem(MenuItem&, MenuController::ExecutionCause)

    #17 0x0000010e129c85 in EditorApplication_CUSTOM_ExecuteMenuItemInternal(ScriptingBackendNativeStringPtrOpaque*, unsigned char)

    #18 0x00000211289246 in (wrapper managed-to-native) UnityEditor.EditorApplication:ExecuteMenuItemInternal (string,bool) [{0x7f8c56300d68} + 0x86] (0x2112891c0 0x2112892fd) [0x15d142a80 - Unity Child Domain]

    #19 0x00000211288933 in UnityEditor.ShortcutManagement.MenuItemEntryDiscoveryInfo:<.ctor>b__7_0 (UnityEditor.ShortcutManagement.ShortcutArguments) [{0x7f8c53bd1dc0} + 0x23] [/Users/bokken/build/output/unity/unity/Modules/ShortcutManagerEditor/ShortcutAttributeDiscoveryProvider.cs :: 140u] (0x211288910 0x21128893c) [0x15d142a80 - Unity Child Domain]

    #20 0x00000163f2bfbc in mono_jit_runtime_invoke

    #21 0x000001640e2083 in do_runtime_invoke

    #22 0x000001640e1fc0 in mono_runtime_invoke

    #23 0x0000010eb19f17 in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)

    #24 0x0000010eaf4e16 in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)

    #25 0x0000010ec26366 in Scripting::UnityEditor::EditorApplicationProxy::Internal_CallGlobalEventHandler(ScriptingExceptionPtr*)

    #26 0x0000010f5fd14a in CallGlobalInputEvent(InputEvent const&)

    #27 0x00000110c083f5 in ForwardKeyEvent(NSEvent*)

    #28 0x00000110c084fb in -[UnityMainMenu performKeyEquivalent:]

    #29 0x007ff82174e58d in routeKeyEquivalent

    #30 0x007ff821167830 in -[NSApplication(NSEvent) sendEvent:]

    #31 0x00000110c071ee in -[EditorApplicationPrincipalClass sendEvent:]

    #32 0x007ff82142018b in -[NSApplication _handleEvent:]

    #33 0x007ff820fe8d3e in -[NSApplication run]

    #34 0x007ff820fbcc97 in NSApplicationMain

    #35 0x00000110c0799c in EditorMain(int, char const**)

    #36 0x00000110c07cb9 in main

    #37 0x0000011f3ad52e in (Unknown)
     
  4. MustEat

    MustEat

    Joined:
    Jul 15, 2018
    Posts:
    18
    @plu83 - Of note, when I relaunch the Editor, I do see this warning:

    Couldn't parse HID descriptor with fast parser. Using fallback
    UnityEngine.InputSystem.InputManager:OnNativeDeviceDiscovered (int,string)
    UnityEngineInternal.Input.NativeInputSystem:NotifyDeviceDiscovered (int,string) (at /Users/bokken/build/output/unity/unity/Modules/Input/Private/Input.cs:129)

    Nothing else at all.
     
  5. MustEat

    MustEat

    Joined:
    Jul 15, 2018
    Posts:
    18
    I actually think the first error I shared was a red herring. The crash details above give a better representation of the problem. This is on MacOS Monterrey iMac (Retina 5K, 27-inch, Late 2015) Intel.
     
  6. MustEat

    MustEat

    Joined:
    Jul 15, 2018
    Posts:
    18
    I just disabled all my custom systems and that cleared the mystery leak. I'll add them back one by one and trace it manually.
     
  7. plu83

    plu83

    Unity Technologies

    Joined:
    Jul 17, 2020
    Posts:
    6
    Sorry for the delayed response. That crash is a known issue that has a fix incoming for 2022.2. It can also be reproduced by having the standalone profiler open and closing the editor.
     
  8. djarcas

    djarcas

    Joined:
    Nov 15, 2012
    Posts:
    246
    ========== OUTPUTTING STACK TRACE ==================

    0x00007FFA92DA3557 (Unity) DebugDidSyncFence_NoLock
    0x00007FFA92DA345C (Unity) DebugDidSyncFence
    0x00007FFA92DACC0F (Unity) CompleteFenceInternal
    0x00007FFA93093A87 (Unity) GeometryJobTasks::putGeometryJobTask
    0x00007FFA930939AA (Unity) GfxDevice::putGeometryJobFence
    0x00007FFA949AB7DF (Unity) GfxDeviceWorker::RunCommand
    0x00007FFA949B750B (Unity) GfxDeviceWorker::RunExt
    0x00007FFA949B7628 (Unity) GfxDeviceWorker::RunGfxDeviceWorker
    0x00007FFA92FCF31D (Unity) Thread::RunThreadWrapper
    0x00007FFAE40B26BD (KERNEL32) BaseThreadInitThunk
    0x00007FFAE574DFB8 (ntdll) RtlUserThreadStart

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


    Just turned up in Unity 2023.1 and this is LITERALLY the only page on the internet that mentions these keywords. Is there any sort of workaround?
     
  9. firelight_jaden

    firelight_jaden

    Joined:
    Aug 9, 2022
    Posts:
    6
    Also seeing this in Unity 2022.2.9f1. This occurs for me when stopping the game in editor.
     
  10. plu83

    plu83

    Unity Technologies

    Joined:
    Jul 17, 2020
    Posts:
    6
    What is the exact version of 2023.1 that are you using?
     
  11. br0br0br0

    br0br0br0

    Joined:
    Feb 26, 2014
    Posts:
    10
    I'm getting the exact same crash in 2022.2.9f1 on win10. Happens pretty frequently for me whilst the game is running and I'm making changes in the scene and inspector; will also happen occasionaly when stopping the game in editor. Any suggestions?

    Code (CSharp):
    1. ========== OUTPUTTING STACK TRACE ==================
    2.  
    3. 0x00007FF6BD316CA7 (Unity) DebugDidSyncFence_NoLock
    4. 0x00007FF6BD316B9C (Unity) DebugDidSyncFence
    5. 0x00007FF6BD31FB4F (Unity) CompleteFenceInternal
    6. 0x00007FF6BD60C507 (Unity) GeometryJobTasks::PutGeometryJobTask
    7. 0x00007FF6BD60C42A (Unity) GfxDevice::PutGeometryJobFence
    8. 0x00007FF6BEEE76DF (Unity) GfxDeviceWorker::RunCommand
    9. 0x00007FF6BEEF315B (Unity) GfxDeviceWorker::RunExt
    10. 0x00007FF6BEEF3278 (Unity) GfxDeviceWorker::RunGfxDeviceWorker
    11. 0x00007FF6BD548DF7 (Unity) Thread::RunThreadWrapper
    12. 0x00007FFEE2407604 (KERNEL32) BaseThreadInitThunk
    13. 0x00007FFEE33C26A1 (ntdll) RtlUserThreadStart
     
  12. RichyHuang

    RichyHuang

    Joined:
    Aug 24, 2020
    Posts:
    10
    This solution worked for me
     

    Attached Files:

    eggsamurai likes this.