# Crash at FlushQueuedReferences when using Timer

**URL:** <https://forums.unrealengine.com/t/crash-at-flushqueuedreferences-when-using-timer/2446162>\
**Category:** C++\
**Tags:** garbage-collector, timer, unreal-engine, crash, question, CPP\
**Created:** [April 8, 2025, 8:52am UTC](https://forums.unrealengine.com/t/crash-at-flushqueuedreferences-when-using-timer/2446162 "2025-04-08T08:52:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JulianPW](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JulianPW](https://forums.unrealengine.com/u/JulianPW)\
**Post date:** [April 8, 2025, 8:52am UTC](https://forums.unrealengine.com/t/crash-at-flushqueuedreferences-when-using-timer/2446162/1 "2025-04-08T08:52:07Z")

</div>

Hello,  
I am currently trying to figure out where the following crash comes from.

```auto
LogThreadingWindows: Error: Runnable thread Background Worker #26 crashed.
LogWindows: Error: === Critical error: ===
LogWindows: Error:
LogWindows: Error: Fatal error!
LogWindows: Error:
LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff
LogWindows: Error:
LogWindows: Error: [Callstack] 0x00007ff72611904b Project.exe!UE::GC::TBatchDispatcher<UE::GC::TReachabilityProcessor<5> >::FlushQueuedReferences() []

LogWindows: Error: [Callstack] 0x00007ff72613b8bb Project.exe!UE::GC::TFastReferenceCollector<UE::GC::TReachabilityProcessor<5>,UE::GC::TReachabilityCollector<5> >::ProcessObjectArray() []

LogWindows: Error: [Callstack] 0x00007ff7260d3933 Project.exe!FEnumBitfieldTest::`vector deleting destructor'() []

LogWindows: Error: [Callstack] 0x00007ff726110a00 Project.exe!UE::Tasks::Private::TExecutableTaskBase<`UE::GC::FRealtimeGC::BeginInitialReferenceCollection'::`5'::<lambda_1>,void,void>::ExecuteTask() []

LogWindows: Error: [Callstack] 0x00007ff72598b5eb Project.exe!UE::Tasks::Private::FTaskBase::TryExecuteTask() []

LogWindows: Error: [Callstack] 0x00007ff725936a8f Project.exe!LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask * __ptr64__ cdecl(bool),48>::TTaskDelegateImpl<`LowLevelTasks::FTask::Init<`UE::Tasks::Private::FTaskBase::Init'::`2'::<lambda_1> >'::`11'::<lambda_1>,0>::CallAndMove() []

LogWindows: Error: [Callstack] 0x00007ff72571a1ce Project.exe!LowLevelTasks::FTask::ExecuteTask() []

LogWindows: Error: [Callstack] 0x00007ff725719f47 Project.exe!LowLevelTasks::FScheduler::ExecuteTask() []

LogWindows: Error: [Callstack] 0x00007ff7256fd132 Project.exe!LowLevelTasks::FScheduler::TryExecuteTaskFrom<LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue,&LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue::DequeueGlobal,0>() []

LogWindows: Error: [Callstack] 0x00007ff72573f402 Project.exe!LowLevelTasks::FScheduler::WorkerMain() []

LogWindows: Error: [Callstack] 0x00007ff725709ad0 Project.exe!UE::CompressedBuffer::Private::FHeader::CalculateCrc32() []

LogWindows: Error: [Callstack] 0x00007ff7258e2323 Project.exe!FThreadImpl::Run() []

LogWindows: Error: [Callstack] 0x00007ff725ce3de2 Project.exe!FRunnableThreadWin::Run() []

LogWindows: Error: [Callstack] 0x00007ff725cd7837 Project.exe!FRunnableThreadWin::GuardedRun() []

LogWindows: Error: [Callstack] 0x00007ffe5a0d7374 KERNEL32.DLL!UnknownFunction []
LogWindows: Error:
LogWindows: Error: Crash in runnable thread Background Worker #26

```

From a static UFUNCTION I want to call another static UFUNCTION from a timer. For that I use `FTimerDelegate::CreateStatic` with a reference to my function and then `GetWorld()->GetTimerManager().SetTimer()`

I suspect this bug to do something with the garbage collector, why I am using `gc.CollectGarbageEveryFrame = 1` to debug it and to reproduce it. Without that option, the crash does not happen regularly, but often enough.

If I directly call the functions instead of using the timer, this crash does not happen.

Any idea on how to debug or solve this? Or might there an alternative for Timers?

---

<div class="post-metadata">

**Author:** ![JulianPW](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JulianPW](https://forums.unrealengine.com/u/JulianPW)\
**Post date:** [April 8, 2025, 10:15am UTC](https://forums.unrealengine.com/t/crash-at-flushqueuedreferences-when-using-timer/2446162/2 "2025-04-08T10:15:12Z")

</div>

In editor, sometimes get

```auto
     [Inlineframe] UnrealEditor-CoreUObject.dll!UE::GC::TReferenceBatcher<UE::GC::FMutableReference,UE::GC::FResolvedMutableReference,UE::GC::TReachabilityProcessor<5>>::DrainValidated(const unsigned int Num) Zeile 1560	C++
     >	[Inlineframe] UnrealEditor-CoreUObject.dll!UE::GC::TReferenceBatcher<UE::GC::FMutableReference,UE::GC::FResolvedMutableReference,UE::GC::TReachabilityProcessor<5>>::FlushQueues() Zeile 1424	C++
          UnrealEditor-CoreUObject.dll!UE::GC::TBatchDispatcher<UE::GC::TReachabilityProcessor<5>>::FlushQueuedReferences() Zeile 2942	C++
          UnrealEditor-CoreUObject.dll!UE::GC::TFastReferenceCollector<UE::GC::TReachabilityProcessor<5>,UE::GC::TReachabilityCollector<5>>::ProcessObjectArray(UE::GC::FWorkerContext & Context) Zeile 718	C++
          [Inlineframe] UnrealEditor-CoreUObject.dll!CollectReferences::__l3::<lambda_1>::operator()(void *) Zeile 853	C++
          UnrealEditor-CoreUObject.dll!`CollectReferences<UE::GC::TReachabilityCollector<5>,UE::GC::TReachabilityProcessor<5>>'::`3'::<lambda_1>::<lambda_invoker_cdecl>(void * P, UE::GC::FWorkerContext & C) Zeile 853	C++
          [Inlineframe] UnrealEditor-CoreUObject.dll!UE::GC::ProcessAsync::__l40::<lambda_1>::operator()() Zeile 5542	C++
          [Inlineframe] UnrealEditor-CoreUObject.dll!Invoke(UE::GC::ProcessAsync::__l40::<lambda_1> &) Zeile 47	C++
          UnrealEditor-CoreUObject.dll!UE::Tasks::Private::TExecutableTaskBase<`UE::GC::ProcessAsync'::`40'::<lambda_1>,void,void>::ExecuteTask() Zeile 701	C++
          UnrealEditor-CoreUObject.dll!UE::Tasks::Private::FTaskBase::TryExecuteTask() Zeile 436	C++
          [Inlineframe] UnrealEditor-CoreUObject.dll!UE::Tasks::Private::FTaskBase::Init::__l2::<lambda_1>::operator()() Zeile 157	C++
          [Inlineframe] UnrealEditor-CoreUObject.dll!LowLevelTasks::FTask::Init::__l11::<lambda_1>::operator()(const bool) Zeile 499	C++
          [Inlineframe] UnrealEditor-CoreUObject.dll!Invoke(LowLevelTasks::FTask::Init::__l11::<lambda_1> &) Zeile 47	C++
          [Inlineframe] UnrealEditor-CoreUObject.dll!LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask * __cdecl(bool),48>::TTaskDelegateImpl<`LowLevelTasks::FTask::Init<`UE::Tasks::Private::FTaskBase::Init'::`2'::<lambda_1>>'::`11'::<lambda_1>,0>::Call(void *) Zeile 162	C++
          UnrealEditor-CoreUObject.dll!LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask * __cdecl(bool),48>::TTaskDelegateImpl<`LowLevelTasks::FTask::Init<`UE::Tasks::Private::FTaskBase::Init'::`2'::<lambda_1>>'::`11'::<lambda_1>,0>::CallAndMove(LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask *__cdecl(bool),48> & Destination, void * InlineData, unsigned int DestInlineSize, bool <Params_0>) Zeile 171	C++
          [Inlineframe] UnrealEditor-Core.dll!LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask * __cdecl(bool),48>::CallAndMove(LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask *__cdecl(bool),48> &) Zeile 308	C++
          UnrealEditor-Core.dll!LowLevelTasks::FTask::ExecuteTask() Zeile 627	C++
          UnrealEditor-Core.dll!LowLevelTasks::FScheduler::ExecuteTask(LowLevelTasks::FTask * & InOutTask) Zeile 150	C++
          UnrealEditor-Core.dll!LowLevelTasks::FScheduler::TryExecuteTaskFrom<LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue,&LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue::DequeueGlobal,0>(LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue * Queue, LowLevelTasks::TLocalQueueRegistry<1024>::FOutOfWork & OutOfWork, bool bPermitBackgroundWork, bool bDisableThrottleStealing) Zeile 350	C++
          UnrealEditor-Core.dll!LowLevelTasks::FScheduler::WorkerMain(LowLevelTasks::FSleepEvent * WorkerEvent, LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue * WorkerLocalQueue, unsigned int WaitCycles, bool bPermitBackgroundWork) Zeile 378	C++
          [Inlineframe] UnrealEditor-Core.dll!LowLevelTasks::FScheduler::CreateWorker::__l2::<Lambdafunktion>() Zeile 70	C++
          [Inlineframe] UnrealEditor-Core.dll!Invoke(LowLevelTasks::FScheduler::CreateWorker::__l2::void <Lambdafunktion>(const TArray<FString,TSizedDefaultAllocator<32>> &, UWorld *, FOutputDevice &) &) Zeile 47	C++
          UnrealEditor-Core.dll!UE::Core::Private::Function::TFunctionRefCaller<`LowLevelTasks::FScheduler::CreateWorker'::`2'::void <Lambdafunktion>(const TArray<FString,TSizedDefaultAllocator<32>> &, UWorld *, FOutputDevice &),void __cdecl(void)>::Call(void * Obj) Zeile 480	C++
          [Inlineframe] UnrealEditor-Core.dll!UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::TFunctionStorage<1>,void __cdecl(void)>::operator()() Zeile 629	C++
          UnrealEditor-Core.dll!FThreadImpl::Run() Zeile 69	C++
          UnrealEditor-Core.dll!FRunnableThreadWin::Run() Zeile 149	C++
          UnrealEditor-Core.dll!FRunnableThreadWin::GuardedRun() Zeile 71	C++
          kernel32.dll!00007ffe5a0d7374()	Unbekannt
          ntdll.dll!00007ffe5a3dcc91()	Unbekannt

```

---

<div class="post-metadata">

**Author:** ![JulianPW](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JulianPW](https://forums.unrealengine.com/u/JulianPW)\
**Post date:** [April 8, 2025, 11:51am UTC](https://forums.unrealengine.com/t/crash-at-flushqueuedreferences-when-using-timer/2446162/3 "2025-04-08T11:51:58Z")

</div>

Similar to here [Editor crashes on startup if uninitialized UPROPERTY object pointer is used in USTRUCT - #11 by anonymous\_user\_528b643b1](https://forums.unrealengine.com/t/editor-crashes-on-startup-if-uninitialized-uproperty-object-pointer-is-used-in-ustruct/385785/11) I had uninitialized AActors\* in a struct. Initializing them with nullptr now prevents the crash from happening, even when using `gc.CollectGarbageEveryFrame = 1`

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [May 8, 2025, 11:52am UTC](https://forums.unrealengine.com/t/crash-at-flushqueuedreferences-when-using-timer/2446162/4 "2025-05-08T11:52:34Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
