Description

Summary

FParticlePerfStatsManager::AddListener(Listener) defaults to bReset=true and calls Reset() synchronously. Reset() only calls FlushRenderingCommands(), then empties WorldToPerfStats, SystemToPerfStats and ComponentToPerfStats, destroying the TUniquePtr<FParticlePerfStats> objects. It never waits for task-graph work. FNiagaraSystemInstanceFinalizeTask captures an FParticlePerfStatsContext (raw FParticlePerfStats*) in its constructor, so if a listener is added mid-tick (e.g. from an actor tick in the same tick group) the queued finalize task later writes through a freed pointer. Licensee ASan report: heap-use-after-free at NiagaraSystemSimulation.cpp (PARTICLE_PERF_STAT_CYCLES_GT(SystemPerfStatsContext, Finalize)), 24 bytes into a 216-byte FParticlePerfStats freed by Reset().

Affects: 5.8.0–5.8.4, //UE5/Main, //UE6/Main (no fix in Dev-Release-5.8/5.9 as of 2026-11-20).

Code (//UE5/Release-5.8 / Main)

  1. ParticlePerfStatsManager.h declares AddListener(..., bool bReset = true); ParticlePerfStats.cpp AddListener calls Reset() synchronously.
  2. ParticlePerfStats.cpp Reset(): FlushRenderingCommands(), null cached object pointers, Empty() the three maps (owning TUniquePtr). No wait on task graph / Niagara async work; no deferred reset.
  3. ParticlePerfStats.h: FParticlePerfStatsContext holds raw FParticlePerfStats*; FParticlePerfStatScope copies the context and writes through it in its destructor.
  4. NiagaraSystemSimulation.cpp: FNiagaraSystemInstanceFinalizeTask constructor builds FParticlePerfStatsContext(World, System); DoTask opens PARTICLE_PERF_STAT_CYCLES_GT(..., Finalize).
  5. Same raw-context pattern elsewhere (same fix should cover): concurrent sim / spawn / instance tick scopes and per-component finalize in NiagaraSystemSimulation.cpp; render-thread proxy contexts in NiagaraComponent.cpp and NiagaraSystemInstanceController.cpp; Cascade concurrent tick/finalize (ParticleSystemComponent.cpp) and ParticleSystemSceneProxy.cpp. The Niagara GPU profiler is not affected (fetches a fresh context in PostResults).

Origin CLs: 14856409 (AddListener/Reset), 15653211 (raw-pointer context), 33495814 (finalize task captures context).

Fix direction

  • A: make Reset() wait for all in-flight Niagara (and Cascade) work before emptying the maps, or defer the reset to a point where all such tasks are guaranteed complete.
  • B: keep retired stats alive until outstanding contexts are released (ref-counted / deferred-free ownership).
  • A generation counter alone does not protect raw pointers tasks already hold.

Workaround (confirmed in code): call AddListener(Listener, false); if a reset is needed, do it while Niagara is idle (not during a world tick).

Steps to Reproduce
  1. Run with ASan enabled and active Niagara systems in the world.
  2. From an actor tick in the same tick group as the Niagara system simulation tick, call FParticlePerfStatsManager::AddListener(Listener) with the default bReset=true.
  3. The queued FNiagaraSystemInstanceFinalizeTask runs after Reset(); ASan reports heap-use-after-free in FParticlePerfStatScope<...Finalize>::~FParticlePerfStatScope (NiagaraSystemSimulation.cpp).
Callstack
ASanErrorCallback()
FParticlePerfStatScope<`FNiagaraSystemInstanceFinalizeTask::DoTask'::`2'::FParticlePerfStatsWriterCycles_GameThread_Finalize>::~FParticlePerfStatScope<`FNiagaraSystemInstanceFinalizeTask::DoTask'::`2'::FParticlePerfStatsWriterCycles_GameThread_Finalize>()
FNiagaraSystemInstanceFinalizeTask::DoTask()
TGraphTask<FNiagaraSystemInstanceFinalizeTask>::ExecuteTask()
UE::Tasks::Private::FTaskBase::TryExecuteTask()
FNamedTaskThread::ProcessTasksNamedThread()
FNamedTaskThread::ProcessTasksUntilIdle()
FTaskGraphCompatibilityImplementation::ProcessUntilTasksComplete()
FTickTaskSequencer::ReleaseTickGroup()
FTickTaskManager::RunTickGroup()
UWorld::RunTickGroup()
UWorld::Tick()
UGameEngine::Tick()
FEngineLoop::Tick()
GuardedMain()
LaunchWindowsStartup()

Have Comments or More Details?

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

0
Login to Vote

Fixed
ComponentUE - Rendering - Architecture - Niagara
Affects Versions5.8
Target Fix5.9
Fix Commit60940772
CreatedNov 20, 2026
ResolvedNov 20, 2026
UpdatedDec 4, 2026
View Jira Issue