VSZue / DonAINavigation

This plugin provides a 3D dynamic pathfinding system for use with Unreal Engine 4. It's primarly designed for Flying AI creatures based in dynamic or procedural worlds that need to solve complex pathfinding tasks.
MIT License
239 stars 113 forks source link

Access violation - code c0000005 #13

Open Atulin opened 6 years ago

Atulin commented 6 years ago

So, the plugin suddenly started making problems. Haven't changed anything about the nav, as I've been dealing with level design recently. And yet – what used to work, now crashes the engine.

Access violation - code c0000005 (first/second chance not available)

UE4Editor_DonAINavigation!TSet<AActor *,DefaultKeyFuncs<AActor *,0>,FDefaultSetAllocator>::FindId() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\core\public\containers\set.h:631]
UE4Editor_DonAINavigation!UBTTask_FlyTo::SchedulePathfindingRequest() [g:\engines\unreal\source\ue_4_20\engine\plugins\marketplace\donainavigation\source\donainavigation\private\behaviortree\bttask_flyto.cpp:92]
UE4Editor_DonAINavigation!UBTTask_FlyTo::ExecuteTask() [g:\engines\unreal\source\ue_4_20\engine\plugins\marketplace\donainavigation\source\donainavigation\private\behaviortree\bttask_flyto.cpp:58]
UE4Editor_AIModule!UBehaviorTreeComponent::ExecuteTask() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\aimodule\private\behaviortree\behaviortreecomponent.cpp:1687]
UE4Editor_AIModule!UBehaviorTreeComponent::ProcessExecutionRequest() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\aimodule\private\behaviortree\behaviortreecomponent.cpp:1448]
UE4Editor_AIModule!UBehaviorTreeComponent::TickComponent() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\aimodule\private\behaviortree\behaviortreecomponent.cpp:1172]
UE4Editor_Engine!FActorComponentTickFunction::ExecuteTickHelper<<lambda_e8384def656dc646af48282ce274db64> >() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\engine\classes\gameframework\actor.h:3095]
UE4Editor_Engine!FActorComponentTickFunction::ExecuteTick() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\engine\private\components\actorcomponent.cpp:797]
UE4Editor_Engine!TGraphTask<FTickFunctionTask>::ExecuteTask() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\core\public\async\taskgraphinterfaces.h:829]
UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\core\private\async\taskgraph.cpp:665]
UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilIdle() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\core\private\async\taskgraph.cpp:585]
UE4Editor_Engine!FTickTaskSequencer::ReleaseTickGroup() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\engine\private\ticktaskmanager.cpp:558]
UE4Editor_Engine!FTickTaskManager::RunTickGroup() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\engine\private\ticktaskmanager.cpp:1455]
UE4Editor_Engine!UWorld::RunTickGroup() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\engine\private\leveltick.cpp:780]
UE4Editor_Engine!UWorld::Tick() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\engine\private\leveltick.cpp:1466]
UE4Editor_UnrealEd!UEditorEngine::Tick() [g:\engines\unreal\source\ue_4_20\engine\source\editor\unrealed\private\editorengine.cpp:1691]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [g:\engines\unreal\source\ue_4_20\engine\source\editor\unrealed\private\unrealedengine.cpp:403]
UE4Editor!FEngineLoop::Tick() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\launch\private\launchengineloop.cpp:3495]
UE4Editor!GuardedMain() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\launch\private\launch.cpp:166]
UE4Editor!GuardedMainWrapper() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\launch\private\windows\launchwindows.cpp:144]
UE4Editor!WinMain() [g:\engines\unreal\source\ue_4_20\engine\source\runtime\launch\private\windows\launchwindows.cpp:223]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

dealt with access violation once before, it was due to the pawn being out of the nav volume bounds. It is not the case this time, I made double-sure of that.

UE 4.20.2, Blueprint project Relevant screenshots: https://imgur.com/gallery/PEV3uwx

Atulin commented 6 years ago

Callstack:

>   UE4Editor-DonAINavigation.dll!TSet<AActor * __ptr64,DefaultKeyFuncs<AActor * __ptr64,0>,FDefaultSetAllocator>::FindId(AActor * Key) Line 631    C++
    [Inline Frame] UE4Editor-DonAINavigation.dll!TSet<AActor *,DefaultKeyFuncs<AActor *,0>,FDefaultSetAllocator>::Contains(AActor *) Line 728   C++
    [Inline Frame] UE4Editor-DonAINavigation.dll!ADonNavigationManager::HasTask(AActor *) Line 1063 C++
    UE4Editor-DonAINavigation.dll!UBTTask_FlyTo::SchedulePathfindingRequest(UBehaviorTreeComponent & OwnerComp, unsigned char * NodeMemory) Line 92 C++
    UE4Editor-DonAINavigation.dll!UBTTask_FlyTo::ExecuteTask(UBehaviorTreeComponent & OwnerComp, unsigned char * NodeMemory) Line 58    C++
    [Inline Frame] UE4Editor-AIModule.dll!UBTTaskNode::WrappedExecuteTask(UBehaviorTreeComponent &) Line 28 C++
    UE4Editor-AIModule.dll!UBehaviorTreeComponent::ExecuteTask(UBTTaskNode * TaskNode) Line 1687    C++
    UE4Editor-AIModule.dll!UBehaviorTreeComponent::ProcessPendingExecution() Line 1486  C++
    UE4Editor-AIModule.dll!UBehaviorTreeComponent::ProcessExecutionRequest() Line 1442  C++
    UE4Editor-AIModule.dll!UBehaviorTreeComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction) Line 1172    C++
    [Inline Frame] UE4Editor-Engine.dll!FActorComponentTickFunction::ExecuteTick::__l2::<lambda_e8384def656dc646af48282ce274db64>::operator()(float) Line 795   C++
    UE4Editor-Engine.dll!FActorComponentTickFunction::ExecuteTickHelper<<lambda_e8384def656dc646af48282ce274db64> >(UActorComponent * Target, bool bTickInEditor, float DeltaTime, ELevelTick TickType, const FActorComponentTickFunction::ExecuteTick::__l2::<lambda_e8384def656dc646af48282ce274db64> & ExecuteTickFunc) Line 3095    C++
    UE4Editor-Engine.dll!FActorComponentTickFunction::ExecuteTick(float DeltaTime, ELevelTick TickType, ENamedThreads::Type CurrentThread, const TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 797   C++
    [Inline Frame] UE4Editor-Engine.dll!FTickFunctionTask::DoTask(ENamedThreads::Type) Line 270 C++
    UE4Editor-Engine.dll!TGraphTask<FTickFunctionTask>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 829  C++
    [Inline Frame] UE4Editor-Core.dll!FBaseGraphTask::Execute(TArray<FBaseGraphTask *,FDefaultAllocator> & CurrentThread, ENamedThreads::Type) Line 498 C++
    UE4Editor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread(int QueueIndex, bool bAllowStall) Line 665 C++
    UE4Editor-Core.dll!FNamedTaskThread::ProcessTasksUntilIdle(int QueueIndex) Line 585 C++
    UE4Editor-Engine.dll!FTickTaskSequencer::ReleaseTickGroup(ETickingGroup WorldTickGroup, bool bBlockTillComplete) Line 558   C++
    UE4Editor-Engine.dll!FTickTaskManager::RunTickGroup(ETickingGroup Group, bool bBlockTillComplete) Line 1455 C++
    UE4Editor-Engine.dll!UWorld::RunTickGroup(ETickingGroup Group, bool bBlockTillComplete) Line 780    C++
    UE4Editor-Engine.dll!UWorld::Tick(ELevelTick TickType, float DeltaSeconds) Line 1466    C++
    UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1691    C++
    UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 403   C++
    UE4Editor.exe!FEngineLoop::Tick() Line 3495 C++
    [Inline Frame] UE4Editor.exe!EngineTick() Line 62   C++
    UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 166   C++
    UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 209   C++
    [Inline Frame] UE4Editor.exe!invoke_main() Line 102 C++
    UE4Editor.exe!__scrt_common_main_seh() Line 283 C++
    kernel32.dll!BaseThreadInitThunk() Unknown
    ntdll.dll!RtlUserThreadStart() Unknown
jcageman commented 6 years ago

Got the same error and stacktrace. The issue in my case is that the actor which does a pathfinding request is outside of the manager range

    NavigationManager =  UDonNavigationHelper::DonNavigationManagerForActor(pawn);
    if (NavigationManager->HasTask(pawn) && !QueryParams.bForceRescheduleQuery)
        return EBTNodeResult::Failed; // early exit instead of going through the manager's internal checks and fallback via HandleTaskFailure (which isn't appropriate here)

NavigationManager is a nullptr here in my case, which results in an incorrect dereference on the next line. Current local code to fix the issue:

NavigationManager =  UDonNavigationHelper::DonNavigationManagerForActor(pawn);
if (NavigationManager && NavigationManager->HasTask(pawn) && !QueryParams.bForceRescheduleQuery)
    return EBTNodeResult::Failed; // early exit instead of going through the manager's internal checks and fallback via HandleTaskFailure (which isn't appropriate here)
Atulin commented 6 years ago

The actor was well within the navmesh in my case

jcageman commented 6 years ago

Another case where it could go wrong, since it really seems to be the same crashsite, is that the moment an actor dies this task is still ran (could be timing related). I.e. if the pawn is a nullptr here, you get the same issue, since then also the manager is not found for the pawn.

Atulin commented 6 years ago

The crash occurs as soon as the BT is activated. The pawn is alive and well at the time.

jcageman commented 6 years ago

Why not attach a debugger and find out? It should break at the right spot

Atulin commented 6 years ago

It breaks on FlyTo, throws callstack mentioned above. Not much more, if anything, to work with.