[release/6.0] Fix frequent FuncEval abort upon hitting a breakpoint in an ASP.NET Core web app #58218
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.
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.