UBehaviorTreeComponent Crash changing behavior from controller BP

Hi,

I’m currently working on tags/4.3.0-release and I’m getting crash when I try to change the current behavior tree from a controller event, this doesn’t happen 100% of the times, but almost…
I found that TaskInstanceIdx is -1 in UBehaviorTreeComponent::OnTaskFinished, so I guess there was a pending task on the old BT calling OnTaskFinished and, as you are already returning if “TaskNode == NULL || InstanceStack.Num() == 0 || IsPendingKill()”, I just added “if (TaskInstanceIdx == -1) return;” after “const int32 TaskInstanceIdx = FindInstanceContainingNode(TaskNode);”, it seems to be safe, the crash is gone but I’m not sure if this will leak memory.
Can I keep this fix? or do I have to change the behavior tree only from the previous one and not from the controller blueprint?

Additional information: All my BT tasks are BP, I’m using parallel nodes to walk and aim/attack at the same time, the controller may change the BT on some movement events

Thanks,
Leo Benaducci

Howdy Leo Benaducci,

Thank you for reporting your crash. Could you provide the logs from the crash and your DXdiag so that we may further investigate the issue? Any additional information would be greatly appreciated.

Thanks and have a great day!

Hi Sean,

Sure, I’ve noticed that I was trying to change the behavior tree (using Run Behavior on the AI Controller), but, actually there were two running simultaneously (according to the BT visual debugger)link text, is that possible?

Thanks,
Leo

link text

Your fix is good and safe :slight_smile: Task finish event came from blueprint’s latent action (delay/timer/something similar) and should be ignored when task node is no longer present in active tree.

I’ll add aborting all pending blueprint execution when tree is stopped + your failsafe to engine’s code.

Great!, Thanks