Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0 RC2] Fix to allow entering cooperative GC mode when the thread is in a forbid-suspend-for-debugger region #42630

Merged
merged 1 commit into from
Sep 23, 2020

Conversation

kouvel
Copy link
Member

@kouvel kouvel commented Sep 23, 2020

Fixes #42375

Customer impact

  • When VS breaks a process for managed debugging at an arbitrary time, if it happens during a short window of time, the process does not suspend for the debugger and instead a thread gets stuck in a perpetual spin-wait. VS times out waiting, eventually showing an error.
  • Detaching the debugger also times out, eventually giving an option to terminate the process. The process gets stuck in this deadlocked state and the only option appears to be to forcibly terminate it.
  • A workaround is to disable tiering and profiler-rejit-on-attach when debugging. There are cases where the same issue may occur even then, but they are probably a lot more rare.

Regression?

  • Yes, from 3.1
  • PR Don't suspend for debugger while holding the slot backpatching lock #40060 changed how suspension for the debugger works with a particular lock used by tiering and profiler-rejit-on-attach. The intention was to allow entering cooperative GC mode and the perpetual spin-wait was missed.
  • 3.1 used a different but incomplete solution that was problematic for VS debugger tests and with a bit worse diagnostic experience in some situations

Testing

  • Manual testing with VS/coreclr to induce the problem
  • PAL, coreclr, and libraries tests

Risk

Low:

  • The change provides the originally intended behavior, I'm not aware of any significant risks

…s in a forbid-suspend-for-debugger region

- Port of dotnet#42587 to 5.0 RC2
- Followup to dotnet#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 dotnet#42375
@kouvel kouvel added this to the 5.0.0 milestone Sep 23, 2020
@kouvel kouvel requested review from noahfalk and janvorli September 23, 2020 17:11
@kouvel kouvel self-assigned this Sep 23, 2020
Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. We should consider this for RC2

@jeffschwMSFT jeffschwMSFT added the Servicing-consider Issue for next servicing release review label Sep 23, 2020
@kouvel kouvel merged commit 1744896 into dotnet:release/5.0-rc2 Sep 23, 2020
@kouvel kouvel deleted the CoopFix50rc2 branch September 23, 2020 20:32
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-TieredCompilation-coreclr Servicing-consider Issue for next servicing release review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants