This question was created in reference to: [UE5.5.4 - Crash in FNiagaraRibbonGpuBuffer::Allocate and [Content removed]
Just wanted to call out that since our upgrade from 5.5.4 to 5.6.1, we have also been seeing this crash:
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000028
[ 00 ] FD3D12DynamicRHI::RHILockBuffer (D3D12Buffer.cpp:686)
[ 01 ] FRHICommandListBase::LockBuffer (RHICommandList.h:729)
[ 02 ] FNiagaraRendererRibbons::InitializeVertexBuffersResources (NiagaraRendererRibbons.cpp:2514)
[ 03 ] FNiagaraRendererRibbons::GetDynamicMeshElements (NiagaraRendererRibbons.cpp:963)
[ 04 ] FNiagaraSystemRenderData::GetDynamicMeshElements (NiagaraSystemRenderData.cpp:235)
[ 05 ] FNiagaraSceneProxy::GetDynamicMeshElements (NiagaraComponent.cpp)
[ 06 ] FProjectedShadowInfo::GatherDynamicMeshElementsArray
[ 07 ] FProjectedShadowInfo::GatherDynamicMeshElements
[ 08 ] UE::Trace::FChannel::operator|
[ 09 ] TaskTrace::FTaskTimingEventScope::{ctor}
[ 10 ] UE::Tasks::Private::FTaskBase::TryExecuteTask
[…]
It seems to stem from parallel threads altering the Vertex buffers out from under each other. The call of …
NiagaraRendererRibbons.cpp
// Make sure our ribbon data buffers are setup
VertexBuffers.InitializeOrUpdateBuffers(RHICmdList, GenerationConfig, DynamicDataRibbon->GenerationOutput, SourceParticleData, DynamicDataRibbon->MaxAllocationCount, bShouldUseGPUInit);
… can release or reallocate any of the shared vertex buffers while another thread is within the Lock/Memcpy/Unlock sequence below, operating on the same vertex buffers.
I’ve done a tentative fix locally where I just move the UE::TScopeLock VertexBuffersLock(VertexBuffersGuard) declaration to the top of FNiagaraRendererRibbons::InitializeVertexBuffersResources, making sure only 1 thread can touch the vertex buffers at a time, and am no longer seeing the crash. But I haven’t been able to test that extensively.
I’ll update if this indeed seems to fix the crash for us.