cudaDeviceReset - all CUDA-capable devices are busy or unavailable

I have an c# application that loads a Cuda DLL (via c++ cli).

I’ve noticed that if I have a bad error in the cuda dll (e.g. an invalid pointer) then despite calling cudaDeviceReset in my exception handler, cuda is somehow left in a bad state so that the next call to my dll results in the error “all CUDA-capable devices are busy or unavailable”.

To remedy this I need to restart the c# application. Is this an expected behaviour of cudaDeviceReset or a bug in the gpu driver? This behaviour is making me wish I had put the cuda code into an separate exe and use IPC to communicate with c# (since the exe can be restarted if it has an error without affecting the c# gui).