Static ConstructorHelpers::FClassFinder in UObject constructors can cause deadlock during boot

Project is set with Event driven loading and asynchronous loading enabled

Assume there is a ‘class A’ which has static ConstructorHelpers::FClassFinder in its constructor. There are other classes B and C who both happen to extend Class A

During the boot sequence Class B gets loaded before others. When the main thread reaches initialization of the aforementioned static variable while creating the default object of B, the program can sometimes decide to call ConstructWaitingBootObjects().

This can sometimes lead to calling a CreateDefaultObject on Class C

This causes re-entry to consturctor of Class A in the middle of initializing static ConstructorHelpers::FClassFinder in Class A due to calling CreateDefaultObject on Class B.

When the main thread reaches static ConstructorHelpers::FClassFinder during re-entry, the thread tries to get lock, which is already locked by itself. (_Init_thread_header in thread_safe_statistics.cpp)

Is there a recommended work around about this Issue?

1 Like