Reference count has underflowed while browsing complex materials

[2025.02.17-10.57.56:172][973]MaterialEditorStats: Base pass shader: 932 instructions
Stats: Resources Used: 22
Resource Limit: 64
Samplers Used: 4
Sampler Limit: 32

[2025.02.17-10.57.56:172][973]MaterialEditorStats: Base pass vertex shader: 254 instructions
Stats: Resources Used: 6
Resource Limit: 64
Samplers Used: 0
Sampler Limit: 32

[2025.02.17-10.57.56:172][973]MaterialEditorStats: Texture samplers: 4/16
[2025.02.17-10.57.56:172][973]MaterialEditorStats: Texture Lookups (Est.): VS(3), PS(31)
[2025.02.17-10.57.56:172][973]MaterialEditorStats: Virtual Texture Lookups (Est.): 19
[2025.02.17-10.57.56:172][973]MaterialEditorStats: Virtual Texture Stacks: 5
[2025.02.17-10.57.56:172][973]MaterialEditorStats: User interpolators: 2/4 Scalars (1/4 Vectors) (TexCoords: 2, Custom: 0)
[2025.02.17-10.57.56:172][973]MaterialEditorStats: LWC Constructor usages (Est.): 0 (VS), 8 (PS), 0 (CS)
[2025.02.17-10.57.56:172][973]MaterialEditorStats: LWC Demote usages (Est.): 1 (VS), 0 (PS), 0 (CS)
[2025.02.17-10.57.56:172][973]MaterialEditorStats: LWC Add usages (Est.): 10 (VS), 2 (PS), 0 (CS)
[2025.02.17-10.57.56:172][973]MaterialEditorStats: LWC Subtract usages (Est.): 0 (VS), 4 (PS), 0 (CS)
[2025.02.17-10.57.56:172][973]MaterialEditorStats: LWC Divide usages (Est.): 3 (VS), 0 (PS), 0 (CS)
[2025.02.17-10.57.56:172][973]MaterialEditorStats: LWC Multiply Vector Vector usages (Est.): 1 (VS), 2 (PS), 0 (CS)
[2025.02.17-10.57.56:172][973]MaterialEditorStats: LWC Other usages (Est.): 5 (VS), 2 (PS), 0 (CS)
[2025.02.17-10.57.56:172][973]MaterialEditorStats: Shader Count: 13
[2025.02.17-10.57.56:172][973]MaterialEditorStats: Preshaders: 34  (33 param fetches, 87 ops)
[2025.02.17-10.57.56:922][ 31]LogWindows: Error: appError called: Assertion failed: NumRefs >= 0 [File:P:\UnrealEngine\Engine\Source\Runtime\RHI\Public\RHIResources.h] [Line: 147] 
Reference count has underflowed.

[2025.02.17-10.57.56:922][ 31]LogWindows: Windows GetLastError: The operation completed successfully. (0)

Engines: 5.5.1, 5.5.2, 5.5.3 (from source/from launcher)
Any projects.
Any complex materials (including the ones shipped with Quixel sample projects, for example)
DX12
Last NVIDIA drivers 572.16

Crash occurs while you just browsing the material, not saving, not applying, just moving the cursor around.
Was absolutely fine on 5.4 with the same materials.

Sometimes it has a different crash:

[2025.02.17-11.17.20:542][280]LogStats: FPlatformStackWalk::StackWalkAndDump -  0.136 s
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: === Handled ensure: ===
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: 
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: Ensure condition failed: EnumHasAnyFlags(AccessModeState.Access, Access)  [File:P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderGraphValidation.cpp] [Line: 667] 
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: Resource VirtualTexture_PageTable is in external access mode and is valid for access with the following states: SRVCompute|SRVGraphicsPixel|SRVGraphicsNonPixel, but is being used in pass SlateUI Title = ProjectName - Unreal Editor/CanvasFlush/FMatExpressionPreview MaterialExpressionTextureSampleParameter2D_6/VirtualTextureEndUpdate/VirtualTexturePageTableUpdates/PageTableUpdate (Mip: 0) with access RTV.
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: Stack: 
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab4e6f9c UnrealEditor-RenderCore.dll!`FRDGUserValidation::ValidateExternalAccess'::`2'::<lambda_1>::operator()() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderGraphValidation.cpp:667]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab35c53f UnrealEditor-RenderCore.dll!FRDGUserValidation::ValidateExternalAccess() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderGraphValidation.cpp:667]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab2f94d7 UnrealEditor-RenderCore.dll!`FRDGBuilder::SetupPassResources'::`2'::<lambda_2>::operator()() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderGraphBuilder.cpp:2417]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab2f5a73 UnrealEditor-RenderCore.dll!`EnumerateTextureAccess<`FRDGBuilder::SetupPassResources'::`2'::<lambda_2> >'::`2'::<lambda_1>::operator()() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderGraphBuilder.cpp:156]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab2dde36 UnrealEditor-RenderCore.dll!FRDGParameterStruct::EnumerateTextures<`EnumerateTextureAccess<`FRDGBuilder::SetupPassResources'::`2'::<lambda_2> >'::`2'::<lambda_1> >() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Public\RenderGraphParameters.inl:29]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab34d1bf UnrealEditor-RenderCore.dll!FRDGBuilder::SetupPassResources() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderGraphBuilder.cpp:2360]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab33c482 UnrealEditor-RenderCore.dll!FRDGBuilder::ProcessAsyncSetupQueue() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderGraphBuilder.cpp:1681]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab3204dd UnrealEditor-RenderCore.dll!FRDGBuilder::Execute() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderGraphBuilder.cpp:1775]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdaa42176c UnrealEditor-SlateRHIRenderer.dll!FSlateRHIRenderer::DrawWindows_RenderThread() [P:\UnrealEngine\Engine\Source\Runtime\SlateRHIRenderer\Private\SlateRHIRenderer.cpp:1099]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdaa3fcddb UnrealEditor-SlateRHIRenderer.dll!`FSlateRHIRenderer::DrawWindows_Private'::`96'::<lambda_3>::operator()() [P:\UnrealEngine\Engine\Source\Runtime\SlateRHIRenderer\Private\SlateRHIRenderer.cpp:1376]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab2f83d5 UnrealEditor-RenderCore.dll!`FRenderThreadCommandPipe::EnqueueAndLaunch'::`5'::<lambda_1>::operator()() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:1541]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab32724f UnrealEditor-RenderCore.dll!TGraphTask<TFunctionGraphTaskImpl<void __cdecl(void),1> >::ExecuteTask() [P:\UnrealEngine\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:634]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffd797e2e32 UnrealEditor-Core.dll!UE::Tasks::Private::FTaskBase::TryExecuteTask() [P:\UnrealEngine\Engine\Source\Runtime\Core\Public\Tasks\TaskPrivate.h:504]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffd797d89fa UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread() [P:\UnrealEngine\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:779]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffd797d8e9e UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit() [P:\UnrealEngine\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:668]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab340cec UnrealEditor-RenderCore.dll!RenderingThreadMain() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:317]
[2025.02.17-11.17.20:542][280]LogOutputDevice: Error: [Callstack] 0x00007ffdab349564 UnrealEditor-RenderCore.dll!FRenderingThread::Run() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:443]
[2025.02.17-11.17.20:543][280]LogOutputDevice: Error: [Callstack] 0x00007ffd79e1871d UnrealEditor-Core.dll!FRunnableThreadWin::Run() [P:\UnrealEngine\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:159]
[2025.02.17-11.17.20:543][280]LogOutputDevice: Error: [Callstack] 0x00007ffd79e0f01f UnrealEditor-Core.dll!FRunnableThreadWin::GuardedRun() [P:\UnrealEngine\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:79]
[2025.02.17-11.17.20:543][280]LogOutputDevice: Error: [Callstack] 0x00007ffde99c7374 KERNEL32.DLL!UnknownFunction []
[2025.02.17-11.17.20:543][280]LogOutputDevice: Error: [Callstack] 0x00007ffdea9dcc91 ntdll.dll!UnknownFunction []
[2025.02.17-11.17.20:543][280]LogOutputDevice: Error: 
[2025.02.17-11.17.20:544][280]LogStats:                SubmitErrorReport -  0.000 s
[2025.02.17-11.17.20:829][280]LogWindows: Could not start crash report client using ../../../Engine/Binaries/Win64/CrashReportClientEditor-Win64-Debug.exe
[2025.02.17-11.17.20:829][280]LogMemory: Platform Memory Stats for WindowsEditor
[2025.02.17-11.17.20:829][280]LogMemory: Process Physical Memory: 13069.43 MB used, 13079.59 MB peak
[2025.02.17-11.17.20:829][280]LogMemory: Process Virtual Memory: 20054.99 MB used, 20278.67 MB peak
[2025.02.17-11.17.20:829][280]LogMemory: Physical Memory: 25217.32 MB used,  72955.86 MB free, 98173.19 MB total
[2025.02.17-11.17.20:829][280]LogMemory: Virtual Memory: 35490.73 MB used,  160986.45 MB free, 196477.19 MB total
[2025.02.17-11.17.20:829][280]LogStats:                    SendNewReport -  0.286 s
[2025.02.17-11.17.20:829][280]LogStats:             FDebug::EnsureFailed -  0.423 s
[2025.02.17-11.17.21:061][284]LogStats: FPlatformStackWalk::StackWalkAndDump -  0.150 s
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: === Handled ensure: ===
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: 
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: Ensure condition failed: Query->SyncPoint  [File:P:\UnrealEngine\Engine\Source\Runtime\D3D12RHI\Private\D3D12Query.cpp] [Line: 324] 
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: Attempt to get result data for an FRHIRenderQuery that was never used in a command list.
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: Stack: 
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd4157a03d UnrealEditor-D3D12RHI.dll!`FD3D12DynamicRHI::RHIGetRenderQueryResult'::`20'::<lambda_1>::operator()() [P:\UnrealEngine\Engine\Source\Runtime\D3D12RHI\Private\D3D12Query.cpp:324]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd414a4e1a UnrealEditor-D3D12RHI.dll!FD3D12DynamicRHI::RHIGetRenderQueryResult() [P:\UnrealEngine\Engine\Source\Runtime\D3D12RHI\Private\D3D12Query.cpp:324]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd6bcbd397 UnrealEditor-Renderer.dll!FFeedbackGPUFencePool::Poll() [P:\UnrealEngine\Engine\Source\Runtime\Renderer\Private\VT\VirtualTextureFeedback.cpp:134]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd6bc9d925 UnrealEditor-Renderer.dll!FVirtualTextureFeedback::CanMap() [P:\UnrealEngine\Engine\Source\Runtime\Renderer\Private\VT\VirtualTextureFeedback.cpp:235]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd6bc9cf4f UnrealEditor-Renderer.dll!FVirtualTextureSystem::BeginUpdate() [P:\UnrealEngine\Engine\Source\Runtime\Renderer\Private\VT\VirtualTextureSystem.cpp:2801]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd6aa924f4 UnrealEditor-Renderer.dll!FDeferredShadingSceneRenderer::Render() [P:\UnrealEngine\Engine\Source\Runtime\Renderer\Private\DeferredShadingRenderer.cpp:1390]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd6b871886 UnrealEditor-Renderer.dll!RenderViewFamilies_RenderThread() [P:\UnrealEngine\Engine\Source\Runtime\Renderer\Private\SceneRendering.cpp:5431]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd6b82878a UnrealEditor-Renderer.dll!`FRendererModule::BeginRenderingViewFamilies'::`96'::<lambda_3>::operator()() [P:\UnrealEngine\Engine\Source\Runtime\Renderer\Private\SceneRendering.cpp:5734]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffdab2f83d5 UnrealEditor-RenderCore.dll!`FRenderThreadCommandPipe::EnqueueAndLaunch'::`5'::<lambda_1>::operator()() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:1541]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffdab32724f UnrealEditor-RenderCore.dll!TGraphTask<TFunctionGraphTaskImpl<void __cdecl(void),1> >::ExecuteTask() [P:\UnrealEngine\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:634]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd797e2e32 UnrealEditor-Core.dll!UE::Tasks::Private::FTaskBase::TryExecuteTask() [P:\UnrealEngine\Engine\Source\Runtime\Core\Public\Tasks\TaskPrivate.h:504]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd797d89fa UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread() [P:\UnrealEngine\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:779]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd797d8e9e UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit() [P:\UnrealEngine\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:668]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffdab340cec UnrealEditor-RenderCore.dll!RenderingThreadMain() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:317]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffdab349564 UnrealEditor-RenderCore.dll!FRenderingThread::Run() [P:\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:443]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd79e1871d UnrealEditor-Core.dll!FRunnableThreadWin::Run() [P:\UnrealEngine\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:159]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffd79e0f01f UnrealEditor-Core.dll!FRunnableThreadWin::GuardedRun() [P:\UnrealEngine\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:79]
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffde99c7374 KERNEL32.DLL!UnknownFunction []
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: [Callstack] 0x00007ffdea9dcc91 ntdll.dll!UnknownFunction []
[2025.02.17-11.17.21:061][284]LogOutputDevice: Error: 
[2025.02.17-11.17.21:063][284]LogStats:                SubmitErrorReport -  0.000 s

so I assume it could be connected to RTVT somehow

Accidentally deleted my previous post :frowning:

Got almost the same once my landscape material grew by duplicating parts of the graph.

First error:
Error: Ensure condition failed: EnumHasAnyFlags(AccessModeState.Access, Access)
(like yours)

Sometimes i get this error, seems depending on whether i navigate in the graph or zoom in/out:
Attempt to get result data for an FRHIRenderQuery that was never used in a command list. from FD3D12DynamicRHI::RHIGetRenderQueryResult'::'20'::<lambda_1>::operator()() D3D12Query.cpp:324

The final crash happens in:
[Inlined] FRHICommandListBase::GetQueryBatchData(ERenderQueryType) RHICommandList.h:1406

UE 5.5.3 from source
DX 12
NVIDIA 572.42 (same with 572.16)

Update: Update errors after trying several more times with moving around in the graph and zooming in/out.

Yes, the max zoom out makes the crash 100%, and the slow zoomed in movements could give you some time before crash. I tried to split material into functions but it changes nothing.

For example:
M_MS_Puddle by Quixel gonna crash.

Hm, for me material functions do the trick. I moved almost all the texture samplers to functions and now i have no crash in main graph or functions. Each material or function has at most 3 texture samplers. I got an error once but no crash anymore.

So you moved Texture Samplers? I need to try it, because this is exactly the things I only left in the main materials.

After several tries, i suspect the rendering of the textures (samplers) is causing this issue. In most cases if texture samplers are moving into the visible area an error or crash is triggered. May not happen for the first few but at some point it starts…

So yes, try to move the texture samplers to functions. I bet it works then…

After 55 crashes I managed pull off all the samples out to functions and I guess that’s it, basic Texture Sample is the reason of the crash. This is a horrible experience making the development x1000 longer… I hope they gonna fix it soon. Even 3 simple samples in an empty materials crash it. Also probably helps to open the level without materials you currently using.

Multiple crashes in Dark Ruins samples. Zero crashes in my personal project that has 11 texture samples in main shader or so. Difference is I don’t use VTs in personal project.

5.5.4 fixed it, I guess, have no crushes for now.

Affirmative.