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

[release/6.0] Fix frequent FuncEval abort upon hitting a breakpoint in an ASP.NET Core web app #58218

Merged
merged 1 commit into from
Aug 27, 2021

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 26, 2021

Backport of #58217 to release/6.0

/cc @kouvel

Customer Impact

On a new ASP.NET Core web app project targeting .NET 6 with hot reload enabled (enabled by default), a breakpoint on the first line in Main, F5 hits the breakpoint and frequently hits a race condition where a FuncEval is unable to evaluate one of the locals due to a deadlock, and has to be aborted with an error message. The race condition may occur at any time when the debugger attach/break occurs during a short window of time where an assembly is being loaded, it just happens to be hitting that timing frequently in some cases.

Testing

Manual testing with the frequent repro above.

Risk

Low - The same solution is already used for the slot backpatching lock to fix the same type of deadlock.

…ore web app

- `AssemblySpecBindingCache` uses a cooperative-GC-mode data structure for the cache and operates on the cache from inside a lock taken in preemptive-GC-mode
- So when the cache is being used, cooperative-GC-mode is entered while holding the lock, which can in turn suspend for the debugger. Then a FuncEval that also happens to operate on the cache would deadlock on acquiring the lock and would have to be aborted.
- This seems to be happening very frequently when hitting an early breakpoint in a default new ASP.NET Core web app in .NET 6 when hot reload is enabled
- Fixed by using the same solution that was used for the slot backpatching lock. When cooperative-GC-mode would be entered inside the lock, a different lock holder based on `CrstAndForbidSuspendForDebuggerHolder` is used, which prevents the thread from suspending for the debugger while the lock is held. The thread would instead suspend for the debugger after leaving the forbid region after releasing the lock.
@ghost
Copy link

ghost commented Aug 26, 2021

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #58217 to release/6.0

/cc @kouvel

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: kouvel
Labels:

area-AssemblyLoader-coreclr

Milestone: -

@kouvel kouvel added this to the 6.0.0 milestone Aug 26, 2021
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. Once we have a green CI we can merge.

@jeffschwMSFT jeffschwMSFT merged commit bb952db into release/6.0 Aug 27, 2021
@akoeplinger akoeplinger deleted the backport/pr-58217-to-release/6.0 branch August 28, 2021 22:03
@ghost ghost locked as resolved and limited conversation to collaborators Sep 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants