FFastIndexingClassTreeRegistrar used by UCLASS_FAST_ISA_IMPL=2 isn't thread safe

We got crashes casting objects when streaming new levels. This seems to be caused by FFastIndexingClassTree::Register and Unregister remapping class ids in the async loading thread while the main thread is casting.

We’ve reverted UCLASS_FAST_ISA_IMPL to 1 to use the older (seemly) thread safe version.

Hey charcole-

Are you able to reproduce the crash in a new project with no additional content? If so, can you provide the setup steps that lead to the crash occuring? Also, can you provide the callstack and log file from the crash for additional information.

It was a very rare bug (maybe once every few complete playthroughs of our game). Was failing in a CastChecked (even though the object was inherited from the class being casted to). It happened in the same place twice but any cast could have failed.

Can’t provide you with steps as it’s a random timing bug but it really is quite obvious if you look at the code. FFastIndexingClassTree::Register and Unregister happening on the async loading thread, which then changes the ClassTreeIndex of various objects with basically no lock (there’s a lock but not when casting). The method is flawed.

We are aware of this issue. We are going to look at it at some point, but it hasn’t been an issue for us so far because none of our internal projects create new UClasses on any other thread than the game thread.