Fix to allow entering cooperative GC mode when the thread is in a forbid-suspend...
authorKoundinya Veluri <kouvel@users.noreply.github.com>
Wed, 23 Sep 2020 17:08:45 +0000 (13:08 -0400)
committerGitHub <noreply@github.com>
Wed, 23 Sep 2020 17:08:45 +0000 (10:08 -0700)
commitcef5deac746126fddcc435a25bfc6edc0a333c13
tree1de716a7c2e72a7db454dd8a1b74754863845763
parent3492460d0b24b646b351685c060857c60b5d03ca
Fix to allow entering cooperative GC mode when the thread is in a forbid-suspend-for-debugger region (#42587)

- Followup to https://github.com/dotnet/runtime/pull/40060
- In short timing windows if a thread is placed in a pending-suspend-for-debugger state while in a forbid-suspend-for-debugger region, from the above PR it would not suspend for the debugger but it was missed that it can also get stuck in a perpetual spin-wait while entering cooperative GC mode. This causes the thread to not suspend for the debugger (VS times out after waiting) and the thread can only progress by unmarking it for debugger suspension.
- Fixed to break the spin-wait by checking whether the thread is in the forbid region

Fix for https://github.com/dotnet/runtime/issues/42375 in master
src/coreclr/src/vm/threadsuspend.cpp