Intermittent D3D12 UniformBuffer Access Violation Crash in UE 5.5.4 Packaged Builds

Hello Unreal Engine community,

I’m experiencing an intermittent crash in our UE 5.5.4 project related to UniformBuffer handling in the D3D12 RHI. The crash occurs in packaged builds (both Development and Shipping configurations) and is more frequent when teleporting between different locations in the game. I’ve spent considerable time debugging this issue and would appreciate any insights from the community.

Crash Details

The application crashes with an access violation when trying to read from an invalid UniformBuffer pointer:
Unhandled exception thrown: read access violation.
InBuffer was 0xFFFFFFFFFFFFFFBF.

The crash occurs at this line:
uint32 UniformBufferHash = InUniformBuffer->GetLayout().GetHash();

Call Stack

The crash happens in the ValidateBoundUniformBuffer function when binding shader parameters:

[Inline Frame] MyGame.exe!ValidateBoundUniformBuffer(FD3D12UniformBuffer * InUniformBuffer, FRHIShader * InShaderRHI, unsigned int InBufferIndex) Line 54
MyGame.exe!BindUniformBuffer(FD3D12CommandContext & Context, FRHIShader * Shader, EShaderFrequency ShaderFrequency, unsigned int BufferIndex, FD3D12UniformBuffer * InBuffer) Line 67
MyGame.exe!SetShaderParametersOnContext(FD3D12CommandContext & Context, FRHIShader * Shader, EShaderFrequency ShaderFrequency, TArrayView<unsigned char const ,int> InParametersData, TArrayView<FRHIShaderParameter const ,int> InParameters, TArrayView<FRHIShaderParameterResource const ,int> InResourceParameters, TArrayView<FRHIShaderParameterResource const ,int> InBindlessParameters) Line 1101
MyGame.exe!FD3D12CommandContext::RHISetShaderParameters(FRHIComputeShader * Shader, TArrayView<unsigned char const ,int> InParametersData, TArrayView<FRHIShaderParameter const ,int> InParameters, TArrayView<FRHIShaderParameterResource const ,int> InResourceParameters, TArrayView<FRHIShaderParameterResource const ,int> InBindlessParameters) Line 1148
MyGame.exe!FRHICommandSetShaderParameters<FRHIComputeShader>::Execute(FRHICommandListBase & CmdList) Line 124
[Inline Frame] MyGame.exe!FCpuProfilerTrace::FEventScope::{ctor}(unsigned int &) Line 171
MyGame.exe!FRHICommand<FRHICommandSetShaderParameters<FRHIComputeShader>,FRHICommandSetShaderParametersString1640>::ExecuteAndDestruct(FRHICommandListBase & CmdList) Line 1473
MyGame.exe!FRHICommandListBase::Execute() Line 426
MyGame.exe!FRHICommandListExecutor::FTranslateState::Translate(FRHICommandListBase * CmdList) Line 906

Debugging Findings

Through debugging, I’ve discovered:

  1. The InBuffer parameter in BindUniformBuffer is 0xdddddddddddddddd (uninitialized memory marker)
  2. When examining InResourceParameters in the debugger:
  • InResourceParameters[0].Resource is a valid pointer (0x000001af6d0348a0)
  • But its ResourceType is RRT_None and bCommitted is 0
  • The OwnerName shows as Illegal name (block index out of range)
  1. The issue appears to be that FD3D12CommandContext::RetrieveObject<FD3D12UniformBuffer>(Parameter.Resource, GpuIndex) is returning an invalid pointer
  2. The crash is more likely to occur during level transitions or when teleporting between different areas, suggesting it might be related to resource loading/unloading or memory management during these transitions.
  3. The issue only manifests in packaged builds (both Development and Shipping), not in the editor.

My Hypothesis

I believe the root cause is that Parameter.Resource points to memory that has been freed. The resource is likely being released prematurely while still referenced by the shader parameter binding system. Since the issue is more common during teleportation, it might be related to how resources are managed during streaming or level transitions in packaged builds.

Questions

  1. Is there a known issue with UniformBuffer reference counting or memory management in the D3D12 RHI for UE 5.5.4, particularly during level transitions in packaged builds?
  2. What’s the recommended approach to fix this issue? Should I add defensive checks in BindUniformBuffer and RetrieveObject, or is there a more fundamental fix needed?
  3. Are there any engine modifications or project settings that could help prevent this issue?
  4. Are there any best practices for managing shader resources during level transitions that might help avoid this problem?
  5. Could this be related to any specific optimizations that occur in packaged builds but not in the editor?

Environment Details

  • Unreal Engine Version: 5.5.4
  • Platform: Windows
  • Build Configuration: Development and Shipping (packaged builds)
  • GPU: NVIDIA RTX 4070
  • Driver Version: 576.02

Any help or guidance would be greatly appreciated. I can provide additional information if needed.

Thank you!