That error message comes from the Microsoft C++ runtime library - it could be absolutely anything causing it, including something that has nothing to do with CUDA at all.
No. You have to better define your problem. The error message comes from a low level compiler runtime library. Anything compiled or linked into the running application (CUDA, MPI, your code, Microsoft’s compiler runtime code) could be the cause. It is impossible to help based on only that Error message and the 7 lines of pseudo code you posted.