Crash in D3D12Commands.cpp

Hello!

When launching the game, we are in windowed full screen.

If we change to fullscreen and then chaing the resolution, closing the game and starting back the game, we have a crash here :

`…unreal5/Engine/Source/Runtime/D3D12RHI/Private/D3D12Commands.cpp`

In

```

void FD3D12CommandContext::SetRenderTargets(

uint32 NewNumSimultaneousRenderTargets,

const FRHIRenderTargetView* NewRenderTargetsRHI,

const FRHIDepthRenderTargetView* NewDepthStencilTargetRHI

)

```

Here :

```

// Gather the render target views for the new render targets.

FD3D12RenderTargetView* NewRenderTargetViews[MaxSimultaneousRenderTargets];

for (uint32 RenderTargetIndex = 0;RenderTargetIndex < MaxSimultaneousRenderTargets;++RenderTargetIndex)

{

FD3D12RenderTargetView* RenderTargetView = NULL;

if (RenderTargetIndex < NewNumSimultaneousRenderTargets && NewRenderTargetsRHI[RenderTargetIndex].Texture != nullptr)

{

int32 RTMipIndex = NewRenderTargetsRHI[RenderTargetIndex].MipIndex;

int32 RTSliceIndex = NewRenderTargetsRHI[RenderTargetIndex].ArraySliceIndex;

FD3D12Texture* NewRenderTarget = RetrieveTexture(NewRenderTargetsRHI[RenderTargetIndex].Texture);

```

`NewRenderTarget` is `nullptr`.

So this line :

`RenderTargetView = NewRenderTarget->GetRenderTargetView(RTMipIndex, RTSliceIndex);`

crashes the game.

We test `NewRenderTarget` against `nullptr`. Is it the right thing to do?

[Attachment Removed]

Hi,

You can add a null check, but it only hides the real issue. This crash looks similar to the one reported in [this [Content removed] and may be caused by a race condition where the back buffer texture is released before the RHI thread can use it.

Would you be able to provide the crash’s call stack?

Thanks,

Sam

[Attachment Removed]