Context
Projects can turn on the project setting bDoFullyAsyncNavDataGathering to execute navigation mesh building tasks on worker threads. Some of these tasks will access the NavOctree, whose lifetime is managed by UNavigationSystemV1.
Problem
When the user exits the application, UNavigationSystemV1::CleanUp() will immediately execute on the GameThread which destroys the NavOctree and null its reference to it. Navigation tasks may still be executing on other threads and they are not prepared for the NavOctree to be destroyed while the task is running. This is a race condition that can result in null pointer access from the worker thread running the nav task. A licensee has provided one worker thread callstack where this happened.
check(NavSys.GetNavOctree()); FPlatformProcess::Sleep(5.0f); check(NavSys.GetNavOctree());
Callstack of null pointer access (non-GameThread, fatal):
FNavigationOctree::DemandLazyDataGathering (NavigationOctree.cpp:76)
FNavigationDataHandler::DemandLazyDataGathering (NavigationDataHandler.cpp:585)
UNavigationSystemV1::DemandLazyDataGathering (NavigationSystem.cpp:3352)
FRecastTileGenerator::GatherNavigationDataGeometry (RecastNavMeshGenerator.cpp:2092)
FRecastTileGenerator::GatherGeometryFromSources (RecastNavMeshGenerator.cpp:1945)
FRecastTileGenerator::DoWork (RecastNavMeshGenerator.cpp:1875)
FAsyncTaskBase::DoWork (AsyncWork.h:288)
FAsyncTaskBase::DoThreadedWork (AsyncWork.h:312)
Example callstack where NavOctree got nulled before (GameThread, non-fatal):
UnrealEditor-NavigationSystem.dll!UNavigationSystemV1::CleanUp(const FNavigationSystem::ECleanupMode Mode) Line 5054 C++
UnrealEditor-NavigationSystem.dll!UNavigationSystemV1::OnBeginTearingDown(UWorld * World) Line 1271 C++
[External Code]
UnrealEditor-UnrealEd.dll!UEditorEngine::TeardownPlaySession(FWorldContext & PieWorldContext) Line 690 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::EndPlayMap() Line 344 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 2475 C++
UnrealEditor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 546 C++
UnrealEditor.exe!FEngineLoop::Tick() Line 5872 C++
[Inline Frame] UnrealEditor.exe!EngineTick() Line 69 C++
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-229415 in the post.
0 |
Component | UE - AI - Navigation |
---|---|
Affects Versions | 5.4.4 |
Target Fix | 5.6 |
Fix Commit | 37791385 |
---|
Created | Nov 1, 2024 |
---|---|
Resolved | Nov 5, 2024 |
Updated | Nov 20, 2024 |