Xcode (MacBook air M1) after executing the code written in C language often freezes and closes, leaving processes in the background making maximum use of the CPU.
Xcode closes on MacBook Air with m1
Maybe the same issue discussed here: https://developer.apple.com/forums/thread/738396
In my case the problem just vanished. But I know of someone else who still has the same issue. Also with C program, very simple, crashes Xcode on the second run.