While playing with alternatives for stress testing, I tried spawning a thread from a module initializer, that would do GC.Collect in a loop and other stress(y) things.
Some tests seem to hang with that:
- InitializeRuntime calls module initializers, which is arbitrary app code and may launch a thread.
- launching a thread waits for the thread to start running.
- to start running, a thread needs to do a reverse PInvoke, which spin-waits for InitializeRuntime to complete.
Perhaps we should finish runtime initialization before calling into module initializers?