Crashes when exiting PIE while executing multiple async tasks. By explicitly executing EndTask and FinishAbort of RecieveAbort, this caused by performing out-of-range in array access to InstanceStack in UBehaviorTreeComponent::StopTree() at the end of PIE.

for (int32 InstanceIndex = InstanceStack.Num() - 1; InstanceIndex >= 0; InstanceIndex--)
	FBehaviorTreeInstance& InstanceInfo = InstanceStack[InstanceIndex];


The workaround is that it doesn't execute EndTask and FinishAbort in BehaviorTree's Abort processing, but it shouldn't always cause a crash.

Steps to Reproduce

1. Open attached project in Editor.
2. Play in editor and press Esc key.
At that time, crash in editor.

[Inline Frame] UE4Editor-AIModule.dll!TArray<FBehaviorTreeInstance,FDefaultAllocator>::RangeCheck(int) Line 611	C++
[Inline Frame] UE4Editor-AIModule.dll!TArray<FBehaviorTreeInstance,FDefaultAllocator>::operator[](int) Line 655	C++
UE4Editor-AIModule.dll!UBehaviorTreeComponent::StopTree(EBTStopMode::Type StopMode) Line 250	C++
UE4Editor-AIModule.dll!UBehaviorTreeComponent::RemoveAllInstances() Line 2127	C++
UE4Editor-AIModule.dll!UBehaviorTreeComponent::UninitializeComponent() Line 102	C++
UE4Editor-Engine.dll!AActor::UninitializeComponents() Line 4341	C++
UE4Editor-UnrealEd.dll!UEditorEngine::TeardownPlaySession(FWorldContext & PieWorldContext) Line 727	C++
UE4Editor-UnrealEd.dll!UEditorEngine::EndPlayMap() Line 324	C++
UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1992	C++
UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 403	C++
UE4Editor.exe!FEngineLoop::Tick() Line 3699	C++
[Inline Frame] UE4Editor.exe!EngineTick() Line 62	C++
UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 174	C++
UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 262	C++
[External Code]	

Have Comments or More Details?

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

Login to Vote

ComponentUE - AI
Affects Versions4.214.22
Target Fix4.23
Fix Commit6649919
Main Commit6835252
CreatedMar 26, 2019
ResolvedMay 27, 2019
UpdatedJun 4, 2019