Description

If an actor that is used in the pooled actor list of UMassActorSpawnerSubsystem is destroyed, it causes a nullptr exception in UMassActorSpawnerSubsystem::SpawnOrRetrieveFromPool. The subsystem attempts to use the first entry of its pooled actors list without checking for a nullptr.

Additionally, this can cause a crash when ReleaseActorToPool is called if the entity that is detached is invalid. The check that is triggered is in UMassRepresentationSubsystem::OnMassAgentComponentEntityDetaching.

Steps to Reproduce
  1. Open MassCrowd level in CitySample
  2. In World Settings, set the Kill Z to -5.0
  3. Open BP_CrowdCharacter and override the function Can Be Pooled to return true
  4. PIE
  5. Delete the Floor from the level
  6. After some of the AI hit the Kill Z and are GC'd
  7. Press Debug Spawn or Debug Clear
Callstack

UnrealEditor_MassActors!UMassActorSpawnerSubsystem::SpawnOrRetrieveFromPool() [D:\UE_5.1\Engine\Plugins\Runtime\MassGameplay\Source\MassActors\Private\MassActorSpawnerSubsystem.cpp:195]
UnrealEditor_MassActors!UMassActorSpawnerSubsystem::ProcessPendingSpawningRequest() [D:\UE_5.1\Engine\Plugins\Runtime\MassGameplay\Source\MassActors\Private\MassActorSpawnerSubsystem.cpp:282]
UnrealEditor_MassActors!UMassActorSpawnerSubsystem::OnPrePhysicsPhaseStarted() [D:\UE_5.1\Engine\Plugins\Runtime\MassGameplay\Source\MassActors\Private\MassActorSpawnerSubsystem.cpp:380]
UnrealEditor_MassActors!TBaseUObjectMethodDelegateInstance<0,UMassActorSpawnerSubsystem,void __cdecl(float),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [D:\UE_5.1\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:618]
UnrealEditor_MassEntity!TMulticastDelegate<void __cdecl(float),FDefaultDelegateUserPolicy>::Broadcast() [D:\UE_5.1\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:975]
UnrealEditor_MassEntity!FMassProcessingPhase::ExecuteTick() [D:\UE_5.1\Engine\Plugins\Runtime\MassEntity\Source\MassEntity\Private\MassProcessingPhaseManager.cpp:66]
UnrealEditor_Engine!FTickFunctionTask::DoTask() [D:\UE_5.1\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:284]
UnrealEditor_Engine!TGraphTask<FTickFunctionTask>::ExecuteTask() [D:\UE_5.1\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:1348]
UnrealEditor_Core!FNamedTaskThread::ProcessTasksNamedThread() [D:\UE_5.1\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:760]
UnrealEditor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [D:\UE_5.1\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:649]
UnrealEditor_Core!FTaskGraphCompatibilityImplementation::WaitUntilTasksComplete() [D:\UE_5.1\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:2203]
UnrealEditor_Engine!FTickTaskSequencer::ReleaseTickGroup() [D:\UE_5.1\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:565]
UnrealEditor_Engine!FTickTaskManager::RunTickGroup() [D:\UE_5.1\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:1592]
UnrealEditor_Engine!UWorld::RunTickGroup() [D:\UE_5.1\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:794]
UnrealEditor_Engine!UWorld::Tick() [D:\UE_5.1\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1537]
UnrealEditor_UnrealEd!UEditorEngine::Tick() [D:\UE_5.1\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:1890]
UnrealEditor_UnrealEd!UUnrealEdEngine::Tick() [D:\UE_5.1\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:517]
UnrealEditor!FEngineLoop::Tick() [D:\UE_5.1\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:5369]
UnrealEditor!GuardedMain() [D:\UE_5.1\Engine\Source\Runtime\Launch\Private\Launch.cpp:202]
UnrealEditor!GuardedMainWrapper() [D:\UE_5.1\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:107]
UnrealEditor!LaunchWindowsStartup() [D:\UE_5.1\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:244]
UnrealEditor!WinMain() [D:\UE_5.1\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:282]
UnrealEditor!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-180683 in the post.

0
Login to Vote

Unresolved
ComponentUE - AI - Mass
Affects Versions5.1.1
Target Fix5.5
CreatedMar 19, 2023
UpdatedFeb 29, 2024