Description

User reported encountering a deadlock between GameThread and AsyncLoadingThread and provided two callstacks.

User quote

I've been running into a deadlock intermittently with a custom blueprint console command that causes a freeze.

The command involves spawning objects and getting data from TSoftObjectPtrs to some DataAssets. This involves a LoadSynchronous() on the TSoftObjectPtr.

The deadlock seems to occur from the GameThread acquiring the lock for FUObjectArray->ObjObjectsCritical, and then getting to FAsyncLoadingThread::FlushLoading(int) where it begins to wait. Meanwhile, the FAsyncLoadingThread attempts to lock ObjObjectsCritical with FUObjectArray::LockInternalArray, therefore getting stuck where FAsyncLoadingThread is waiting to lock ObjObjectsCritical while the GameThread is waiting for FAsyncLoadingThread to finish.

Callstack

==============
GameThread:
FAsyncLoadingThread::FlushLoading(int) AsyncLoading.cpp:7502
FlushAsyncLoading(int) AsyncPackageLoader.cpp:280
LoadPackageInternal(UPackage *,const FPackagePath &,unsigned int,FLinkerLoad *,FArchive *,const FLinkerInstancingContext *,const FPackagePath *) UObjectGlobals.cpp:1508
[Inlined] LoadPackage(UPackage *,const FPackagePath &,unsigned int,FArchive *,const FLinkerInstancingContext *,const FPackagePath *) UObjectGlobals.cpp:1855
LoadPackage(UPackage *,const wchar_t *,unsigned int,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1836
ResolveName(UObject *&,FString &,bool,bool,unsigned int,const FLinkerInstancingContext *) UObjectGlobals.cpp:1111
StaticLoadObjectInternal(UClass *,UObject *,const wchar_t *,const wchar_t *,unsigned int,UPackageMap *,bool,const FLinkerInstancingContext *) UObjectGlobals.cpp:1194
StaticLoadObject(UClass *,UObject *,const wchar_t *,const wchar_t *,unsigned int,UPackageMap *,bool,const FLinkerInstancingContext *) UObjectGlobals.cpp:1273
FSoftObjectPath::TryLoad(FUObjectSerializeContext *) SoftObjectPath.cpp:536
FSoftObjectPtr::LoadSynchronous() SoftObjectPtr.h:54
[Inlined] TSoftObjectPtr<USomeDataAsset>::LoadSynchronous() SoftObjectPtr.h:308

=========
AsyncLoadingThread:
[Inlined] Windows::EnterCriticalSection(Windows::CRITICAL_SECTION *) MinimalWindowsApi.h:229
[Inlined] FWindowsCriticalSection::Lock() WindowsCriticalSection.h:44
[Inlined] FUObjectArray::LockInternalArray() UObjectArray.h:939
FUObjectArray::AllocateUObjectIndex(UObjectBase *,bool) UObjectArray.cpp:197
UObjectBase::AddObject(FName,EInternalObjectFlags) UObjectBase.cpp:212
[Inlined] UObjectBase::

{ctor}

(UClass *,EObjectFlags,EInternalObjectFlags,UObject *,FName) UObjectBase.cpp:129
StaticAllocateObject(const UClass *,UObject *,FName,EObjectFlags,EInternalObjectFlags,bool,bool *,UPackage *) UObjectGlobals.cpp:3305
StaticConstructObject_Internal(const FStaticConstructObjectParameters &) UObjectGlobals.cpp:4199
[Inlined] NewObject(UObject *,FName,EObjectFlags,UObject *,bool,FObjectInstancingGraph *) UObjectGlobals.h:1656
CreatePackage(const wchar_t *) UObjectGlobals.cpp:957
FAsyncPackage::CreateLinker() AsyncLoading.cpp:6137
FAsyncPackage::Event_CreateLinker() AsyncLoading.cpp:1835
<lambda_1acefc6c20c91e5667d506c40e7d1de2>::operator()(FAsyncLoadEventArgs &) AsyncLoading.cpp:1805
[Inlined] UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::TFunctionStorage<0>,void __cdecl(FAsyncLoadEventArgs &)>::operator()(FAsyncLoadEventArgs &) Function.h:602
[Inlined] FAsyncLoadEventQueue::PopAndExecute(FAsyncLoadEventArgs &) AsyncLoadingThread.h:107
FAsyncLoadingThread::ProcessAsyncLoading(int &,bool,bool,float,FFlushRequest &) AsyncLoading.cpp:4393
FAsyncLoadingThread::TickAsyncThread(bool,bool,float,bool &,FFlushRequest &) AsyncLoading.cpp:5297
FAsyncLoadingThread::Run() AsyncLoading.cpp:5222
FRunnableThreadWin::Run() WindowsRunnableThread.cpp:146
FRunnableThreadWin::GuardedRun() WindowsRunnableThread.cpp:79

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-177022 in the post.

0
Login to Vote

Cannot Reproduce
ComponentUE - Foundation - Core - UObject
Affects Versions5.1
Target Fix5.3
CreatedFeb 14, 2023
ResolvedMay 8, 2023
UpdatedAug 9, 2023
View Jira Issue