Data race in async RDG graph deletion: Nanite Materials FUpdater::End() writes into the next frame's FSceneCullingBuilder → check(UploadDataProxy == nullptr), RendererPrivateUtils.h:317 (UE 5.8.4, macOS)

Summary

In a packaged Development game on UE 5.8.4 (CL 58902052, launcher build, unmodified engine) we get a rare fatal assert UploadDataProxy == nullptr at Runtime/Renderer/Private/RendererPrivateUtils.h:317 (TBufferScatterUploader::Reserve), reached from FSceneCullingBuilder::ProcessPostSceneUpdate (or UploadToGPU) ← FSceneCulling::FUpdater::PostSceneUpdate ← FScene::Update.

The cause is a data race in the engine. The async RDG graph deleter of the previous frame runs Nanite::FMaterialsSceneExtension::FUpdater::End() → SyncAllTasks() → UE::Tasks::Wait(TaskHandles) on scene-persistent task handles while the render thread is already replacing those handles for the next frame. FTaskBase::AddPrerequisites loads the raw FTaskBase* and calls Subsequents.PushIfNotClosed() on it before taking a reference, so if the render thread released that task in between, the push writes into freed memory at task + 0x118. That block (FMemory::Malloc(0x180, 0x80), 512-byte bin of MallocBinned3) is reused by the very next FSceneCullingBuilder (new of 0x1F0 bytes, same bin; observed in ~94 % of frames), and BlockDataUploader.UploadDataProxy sits at block offset 0x118. The stale push stores a pointer to the “Waiting Task” there and the next Reserve() asserts.

In every one of our 12 crash reports one worker thread is parked in:

FRDGBuilder::FAsyncDeleter → FRDGAllocator::ReleaseAll → ~FSceneExtensionsUpdaters
  → FSceneExtensionsUpdaters::End → UE::Tasks::Wait<TStaticArray<FTaskHandle,6>> → FTaskBase::Wait

r.SceneCulling.Async.Update=0 does not prevent it (the assert then fires on the render thread). FSkinningSceneExtension::FUpdater::End() has the same pattern with its 7 handles.

What Type of Bug are you experiencing?

Rendering (Graphics / Niagara)

Steps to Reproduce

Natural reproduction is rare (12 crashes over a few days of automated runs of a small landscape scene with one skeletal character). It is deterministic with a debugger-forced thread interleaving, no code changes (2 of 2 attempts):

  1. Break in FTaskBase::AddPrerequisites<TStaticArray<FTaskHandle,6>> on a worker thread that is inside FRDGBuilder::FAsyncDeleter, right after the first handle pointer P is loaded; suspend only that thread.
  2. Continue. Break in FSceneCulling::BeginUpdate right after new FSceneCullingBuilder; the returned block equals P on the next allocation.
  3. After the builder’s constructor returns (UploadDataProxy == nullptr), resume the suspended worker.
  4. PushIfNotClosed returns true; Builder.BlockDataUploader.UploadDataProxy now points to the “Waiting Task”; the render thread reaches the check at line 317 in the same frame.

Expected Result

The async graph deleter must not touch scene-owned task handles that the render thread is concurrently replacing; no write into freed/reused memory; no assert.

Observed Result

Use-after-free write of a FTaskBase* into FSceneCullingBuilder::BlockDataUploader.UploadDataProxy, followed by check(UploadDataProxy == nullptr) failing. The waiting worker never wakes up.

Affects Versions

5.8

Platform(s)

Mac

Additional Notes

Platform: macOS 27, Apple Silicon, Metal (SF_METAL_SM6). Packaged Development game, standalone. UE 5.8.4 CL 58902052. A community report with the same stack exists for 5.8.3 on macOS/Metal (forum thread 2835424).

Workaround verified by the same forced-interleaving test: r.RDG.ParallelDestruction=0 together with r.RDG.ParallelExecute=1. With both, FSceneExtensionsUpdaters::End() runs only on the render thread, synchronously (1322 of 1322 frames), and the reproduction above cannot be constructed (0 worker-thread hits in 2105 frames). r.RDG.ParallelDestruction=0 alone is not sufficient while r.RDG.ParallelExecute=2 (the deleter stayed asynchronous in 1403 of 1405 frames). Measured cost in our scene: about +0.04 ms per frame on the render thread.

Possible fix directions: finish (End()) the scene-extension updaters on the render thread before the graph is handed to FAsyncDeleter; or make FScene::Update wait for FRDGBuilder::FAsyncDeleter::LastTask before scene extensions replace their handles; or have SyncAllTasks() copy the handles (taking references) under a lock shared with the code that assigns them.