Behavior Tree crashes when enum metadata changes

I have a behavior tree which has a bunch of selector and sequence nodes. The behavior tree has a blackboard which contains an enum for creature “state” information. Based off of the creature state, the behavior tree does different things.

Well, I later found that I didn’t need half of the states I had listed in my enum variable anymore, so I deleted them. The behavior tree wasn’t using them directly in any of its nodes, so no big deal, right? Wrong.

I can open the blackboard with no issues. I can view the enum object with no issues. However, opening the behavior tree causes a hang and crash. When the behavior tree tries to iterate over each enum, the enum object still contains the old index ID’s of each item. So, the integer sequence is:

[0] 0x000000001769aa80 “EZombieState::NewEnumerator1”

[1] 0x000000001769aae0 “EZombieState::NewEnumerator6”

[2] 0x000000001769ab10 “EZombieState::NewEnumerator7”

[3] 0x000000001769ab40 “EZombieState::NewEnumerator9”

[4] 0x000000001769aab0 “EZombieState::NewEnumerator10”

[5] 0x000000001769aa50 “EZombieState::EZombieState_MAX”

Crashes on: C:\Users\Eric\Documents\Visual Studio 2013\Projects\UnrealEngine-4.7\Engine\Source\Runtime\CoreUObject\Private\UObject\Enum.cpp

Line: 353
bool UEnum::HasMetaData( const TCHAR* Key, int32 NameIndex/=INDEX_NONE/ ) const
NameIndex value is 8, but if you look at the enumerators posted above, 8 doesn’t exist.

Crashes on Line 368 because the NameIndex isn’t a valid entry in the enum.

I kind of figured out a stop gap solution until the bug gets fixed:

What’s going on: When the behavior tree loads, it pulls in its associated blackboard. Then it tries to load in the metadata for the enum values for all of its blackboard enum keys. When enum values get deleted, the behavior tree / blackboard doesn’t get updated and it crashes.

Stop gap solution:
Delete the enum key in your blackboard. The behavior tree won’t try to load the enum metadata for that blackboard key. You’ll have to recreate the enum blackboard key and fix your behavior tree.

Better solution: Use enums in C++ instead of as user defined classes within the editor.

Hi Slayemin,

Thanks for all of the information. It looks like most of what I need, but can you also attach your log file from the [Project]/Saved/Logs folder? That will help us see exactly what cpp file the crash occurs with and why.

Thanks!

Hi again,

I’m glad you were able to find a temporary solution. If you would like to continue the investigation into the crash please let me know by responding to reopen the post. I will be happy to further assist. Please also include the information I have requested so that I can dig deeper into the cause.

Cheers!

Hey Alex,
It’s been a while since I had this crash and after looking into the logs folder, the crash log is gone. I was able to reproduce the crash consistently and isolated the cause down to the referenced cpp file, though you’d probably want to see the call stack and its data which caused the error.

I think the issue is easy enough to reproduce. Create a behavior tree, add some enums to a blackboard, create some behaviors which use a few of those enums, then delete a few enums which are not used, maybe add a few others, and then try to open the behavior tree again within the editor. This is what caused the crash for me and made it so that I couldn’t even open up the behavior tree asset without experiencing a crash.

Hi Slayemin,

Unfortunately I haven’t been able to reproduce this on my end. I’m going to mark this as answered for tracking purposes. If the crash occurs again, please comment and let us know and I’ll be happy to take another look.