Unhandled Exception: EXCEPTION_STACK_OVERFLOW

I am working on a network game, and I am creating a process to swap the player’s control character when a certain button is pressed.
When there is only one player, it works fine, but when there are two players, I get an error like the one in the image. I am not sure what is not working.