Open ryancheung opened 4 years ago
The long running uninterrupted computation will run into problems though. For example, if the program has infinite loop for(;;) { } on one thread and allocates on a second thread, the GC thread suspension will hang in CoreRT today https://github.com/dotnet/corert/issues/7807#issuecomment-537646340
@jkotas So this GC suspension hanging bug still exists in current CoreRT?
Yes, this problem still exists in current CoreRT.
Got it. Thanks for reply.
I managed to make this game demo works in .NET Native in UWP before.
.NET Native has the codegen+runtime feature necessary for the GC to be able to make progress in a case like this. CoreRT has a different codegen so this requires extra work that hasn't happened yet.
I had a demo MonoGame 3.8 game project and try CoreRT with it.
The game use two thread loops, one is a background thread for sending draw commands to a ConcurrentQueue, another is the game loop in main thread that receive draw commands from ConcurrentQueue and draw the game.
After compiled with CoreRT and run, the window just freezed and nothing was showed. Then I debug it with vscode and it seems the Main thread stuck on
Thread::WaitForGC
, sometimes stuck onThreadStore::WaitForSuspendComplete
.I've noticed that the background thread, which is
MirGameTemplate.WindowsDX.exe!MirEngine_MirEngine_GameBase__ActiveSceneDrawLoop()
in the following stack trace, is not suspended and is running in a intential inifinite loop. If I put aThread.Sleep(1)
in this loop then everything is working.Here is a stack trace of threads:
Main Thread
MirGameTemplate.Windows.DX.exe!FinalizerStart
MirGameTemplate.WindowsDX.exe!S_P_CoreLib_System_Threading_Thread_ThreadEntryPoint[]()
*MirGameTemplate.WindowsDX.exe!unsigned int(void )::**
MirGameTemplate.WindowsDX.exe!S_P_CoreLib_System_Threading_Thread_ThreadEntryPoint[]()