Work around potential Mono bug, that hangs the runtime when new threads start #1779
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I suspect the issue is actually with Mono GC and the relatively new mode of suspending threads, which has a few (closed) bugs against it, complaining about hangs. In many of those bugs (you can find them here) switching to the old
preemptive
mode works around the issue. I tried it for our tests, and it seems to solve it too.The issue also vaguely mentioned in https://www.mono-project.com/docs/advanced/runtime/docs/coop-suspend/#thread-startfinish-still-bad
So the fix is to simply set
MONO_THREADS_SUSPEND
topreemptive
in CI before running tests in Mono.Fixes #1766
This workaround seems to solve the issue on my local machine as well as in CI. I did 5+ CI full matrix reruns to confirm. Before the fix a few MacOS legs would time out in every run.
Below is some history of finding this workaround.