Nvwgf2umx.dll causes "A new guard page for the stack cannot be created" pop-up

Hello! We’ve been using NVENC in our product. And we have a bunch of users who experience the guard stack page pop-up. Our survey showed that most of them are on NVidia GPUs. The specific model doesn’t matter though, because this error is being seen on GTX 970, 1660, 1050, 745 and even on RTX 2070.
We have a crash dump from the RTX 2070 user, and the crash dump shows that the error is thrown by some nvwgf2umx.dll’s function:

ntdll!NtRaiseHardError+0x14
KERNELBASE!RaiseFailFastException+0x190
clr!WatsonLastChance+0x200
clr!InternalUnhandledExceptionFilter_Worker+0x33d
clr!COMUnhandledExceptionFilter+0x45
mscoreei!CLRUEFManager::InvokeUEFCallbacks+0x4e
mscoreei!InternalUnhandledExceptionFilter+0x5d
KERNELBASE!UnhandledExceptionFilter+0x1e7
ntdll!RtlUserThreadStart$filt$0+0xa2
ntdll!_C_specific_handler+0x96
ntdll!RtlpExecuteHandlerForException+0xf
ntdll!RtlDispatchException+0x244
ntdll!KiUserExceptionDispatch+0x2e
nvwgf2umx!OpenAdapter12+0xa62a63
nvwgf2umx!OpenAdapter12+0x2179a2
nvwgf2umx!OpenAdapter12+0xa52f31
nvwgf2umx!OpenAdapter12+0x1d1c6
nvwgf2umx!OpenAdapter12+0x24f518
nvwgf2umx!OpenAdapter12+0x247d1b
nvwgf2umx!OpenAdapter12+0x12f359
d3d11!CResource::CLS::FinalConstruct+0x18a
d3d11!TCLSWrappers::CLSFinalConstructFn+0x43
d3d11!CLayeredObjectWithCLS::FinalConstruct+0xa3
d3d11!CDevice::CreateLayeredChild+0x910
d3d11!NDXGI::CDeviceChild::FinalConstruct+0x49
d3d11!NDXGI::CResource::FinalConstruct+0x40
d3d11!NDXGI::CDevice::CreateLayeredChild+0x281
d3d11!NOutermost::CDevice::CreateLayeredChild+0x1bc
d3d11!CDevice::CreateBuffer_Worker+0x189
d3d11!CDevice::CreateBuffer+0x18
...

So the question here is how to prevent NVENC from throwing this error? We’ve either been using NVENC in a wrong way or it’s a bug somewhere in the drivers. At least, how to find out the debug symbols for nvwgf2umx.dll? The user was using the 27.21.14.5167 driver.
Could be caused by the current type of memoryHeap which is NV_ENC_MEMORY_HEAP_SYSMEM_CACHED?

NV_ENC_CREATE_BITSTREAM_BUFFER m_outStream;
m_outStream.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED;