I’ve been having an issue with builds of my project hard crashing at random points (2023.1b14, and happening in 2023.1b20). It would happen seconds or minutes into running the build at seemingly random points.
From debugging the stack traces look to be at different origins. However, all of them have in common that it happens somewhere in either allocation or deallocation of memory. From this pattern I assume this is due to memory corruption from overwrite and/or double deallocation.
Here are some typical examples:
0x00007FFE0C33F222 (UnityPlayer) block_remove
0x00007FFE0C33FA3A (UnityPlayer) tlsf_free
0x00007FFE0B4378C3 (UnityPlayer) DynamicHeapAllocator::smile:eallocate
0x00007FFE0B43EC9B (UnityPlayer) DualThreadAllocator<DynamicHeapAllocator>::TryDeallocate
0x00007FFE0B43B360 (UnityPlayer) MemoryManager::smile:eallocate
0x00007FFE0B6BB13D (UnityPlayer) profiler_start_new_frame
0x00007FFE0B6A366E (UnityPlayer) `InitPlayerLoopCallbacks'::`2'::InitializationProfilerStartFrameRegistrator::Forward
0x00007FFE0B69AAD7 (UnityPlayer) ExecutePlayerLoop
0x00007FFE0B69AC84 (UnityPlayer) ExecutePlayerLoop
0x00007FFE0B69B034 (UnityPlayer) PlayerLoop
0x00007FFE0B8E36BB (UnityPlayer) PerformMainLoop
0x00007FFE0B8E5A1B (UnityPlayer) MainMessageLoop
0x00007FFE0B8E8D80 (UnityPlayer) UnityMainImpl
0x00007FFE0B8E8F8B (UnityPlayer) UnityMain
0x00007FFEBD6A7D32 (UnityPlayer) block_remove
0x00007FFEBD6A854A (UnityPlayer) tlsf_free
0x00007FFEBC7A7983 (UnityPlayer) DynamicHeapAllocator::smile:eallocate
0x00007FFEBC7ACEE2 (UnityPlayer) DelayedPointerDeletionManager::CleanupPendingMainThreadPointersInternal
0x00007FFEBC7AE8A9 (UnityPlayer) DualThreadAllocator<DynamicHeapAllocator>::Allocate
0x00007FFEBC7AAE88 (UnityPlayer) MemoryManager::Allocate
0x00007FFEBCADA630 (UnityPlayer) dynamic_array_detail::dynamic_array_data::resize_buffer
0x00007FFEBC6D6BBC (UnityPlayer) dynamic_array<double,0>::resize_buffer_nocheck
0x00007FFEBC9453EF (UnityPlayer) RenderingCommandBuffer::PPtrResolver<Material>::Resolve
0x00007FFEBC93EAA8 (UnityPlayer) RenderingCommandBuffer::PrepareState
0x00007FFEBC999445 (UnityPlayer) ScriptableRenderContext::ExecuteScriptableRenderLoop
0x00007FFEA2F3BCE2 (GameAssembly) [\Library\Bee\artifacts\WinPlayerBuildProgram\il2cppOutput\cpp\Unity.RenderPipelines.HighDefinition.Runtime__2.cpp:70710] HDRenderPipeline_Render_mD5A5DFADAEB2A8DB36E4261A8154AB6206D56557
0x00007FFEA32056CD (GameAssembly) [\Library\Bee\artifacts\WinPlayerBuildProgram\il2cppOutput\cpp\UnityEngine.CoreModule__4.cpp:27502] RenderPipelineManager_DoRenderLoop_Internal_mB646C8738F4A9859101F3BE94809E2E10BBDB1FB
0x00007FFE9FE70D16 (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2023.1.0b14\Editor\Data\il2cpp\libil2cpp\vm\Runtime.cpp:638] il2cpp::vm::Runtime::InvokeWithThrow
0x00007FFE9FE707B9 (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2023.1.0b14\Editor\Data\il2cpp\libil2cpp\vm\Runtime.cpp:623] il2cpp::vm::Runtime::Invoke
0x00007FFEBC99B1CD (UnityPlayer) ScriptableRenderContext::ExtractAndExecuteRenderPipeline
0x00007FFEBC83A4FC (UnityPlayer) RenderManager::RenderCamerasWithScriptableRenderLoop
0x00007FFEBC83AC5C (UnityPlayer) RenderManager::RenderCameras
0x00007FFEBCA0F45F (UnityPlayer) PlayerRender
0x00007FFEBCA06C37 (UnityPlayer) ExecutePlayerLoop
0x00007FFEBCA06DE4 (UnityPlayer) ExecutePlayerLoop
0x00007FFEBCA07194 (UnityPlayer) PlayerLoop
0x00007FFEBCC4E86B (UnityPlayer) PerformMainLoop
0x00007FFEBCC50BCB (UnityPlayer) MainMessageLoop
0x00007FFEBCC53F30 (UnityPlayer) UnityMainImpl
0x00007FFEBCC5413B (UnityPlayer) UnityMain
0x00007FFE0C33F222 (UnityPlayer) block_remove
0x00007FFE0C33FA3A (UnityPlayer) tlsf_free
0x00007FFE0B4378C3 (UnityPlayer) DynamicHeapAllocator::smile:eallocate
0x00007FFE0B43EC9B (UnityPlayer) DualThreadAllocator<DynamicHeapAllocator>::TryDeallocate
0x00007FFE0B43B360 (UnityPlayer) MemoryManager::smile:eallocate
0x00007FFE0B4380D4 (UnityPlayer) operator delete
0x00007FFE0B6ED36F (UnityPlayer) std::_Tree_val<std::_Tree_simple_types<HWND__ * __ptr64> >::_Erase_tree<std::allocator<std::_Tree_node<HWND__ * __ptr64,void * __ptr64> > >
0x00007FFE0B6EA70F (UnityPlayer) ContainerClear<std::map<DeprecatedFastPropertyNameSerialization,float,std::less<DeprecatedFastPropertyNameSerialization>,std::allocator<std::pair<DeprecatedFastPropertyNameSerialization const ,float> > > >
0x00007FFE0B6DC028 (UnityPlayer) UnityPropertySheet::operator=
0x00007FFE0B6DF777 (UnityPlayer) Material::CopyPropertiesFromMaterial
0x00007FFE0B25FDC4 (UnityPlayer) Material_CUSTOM_CopyPropertiesFromMaterial_Injected
0x00007FFE001B6049 (GameAssembly) [\Library\Bee\artifacts\WinPlayerBuildProgram\il2cppOutput\cpp\Unity.DemoTeam.Hair.Runtime.cpp:16394] HairInstance_UpdateRendererState_mDF3D80D342772090F4792EBA1923809AFDDF3EA9
0x00007FFE001B6A69 (GameAssembly) [\Library\Bee\artifacts\WinPlayerBuildProgram\il2cppOutput\cpp\Unity.DemoTeam.Hair.Runtime.cpp:16193] HairInstance_UpdateRenderingState_m960FD4D03064646506BBED4A8CED51AA88A46A23
0x00007FFE001B30E4 (GameAssembly) [\Library\Bee\artifacts\WinPlayerBuildProgram\il2cppOutput\cpp\Unity.DemoTeam.Hair.Runtime.cpp:14428] HairInstance_HandlePrerequisiteCompleted_m0CE6D3A6CA3FF2827B6961860CA7A58C7B92D6EB
0x00007FFE001B422D (GameAssembly) [\Library\Bee\artifacts\WinPlayerBuildProgram\il2cppOutput\cpp\Unity.DemoTeam.Hair.Runtime.cpp:14480] HairInstance_LateUpdate_mD2B573892A690C28007C6C6858C0E1D174E855E1
To debug this, I first began to deconstruct my scene, which was not very complex (just one animated character). Turning off the hair got rid of the crashes.
I investigated more, and turning off High Quality Line Rendering either on the hair or via HDRP settings also removed the crashes.
Further testing revealed that it was the composition mode the Line Rendering was set to.
Setting the HQ Line Rendering Composition mode to “After Temporal Antialiasing” in the HDRP settings is causing the issue (I had been using it since a custom pass was messing with the depth buffer creating artifacts on the hair. Turning off custom passes did not get rid of the crashes, however.)
(edit: see posts down below)
Here is some more information that might be useful:
- Happens on both il2cpp and mono
- Happens with incremental garbage collection and also without
- Happens on Direct3D_11, Direct3D_12, but seemingly not Vulcan (which ran significantly slower)
- Does not happen in editor (both edit and play mode). It only happens on a build
- It didn’t seem to happen when building development builds. With release builds it would happen quickly (30 sec - 2 min).
- Tested on Windows 10, Intel i9-12900KF, NVIDIA 3090 with latest drivers
- Tested Unity versions: 2023.1b14 and 2023.1b20
I’ve ran the build with the ‘-debugallocator’ cmd line argument, but I couldn’t see any difference in the stack traces.
I’m not sure if I can quickly throw together and test a stripped down project for reproducing as I’m currently very busy, but I will try should it be necessary.