Skip to content

[release/9.0-staging] Fix crash during Async Break when APC and CET are enabled #114932

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

Merged
merged 7 commits into from
May 19, 2025

Conversation

thaystg
Copy link
Member

@thaystg thaystg commented Apr 22, 2025

Backport of #111408 to release/9.0-staging

/cc @thaystg

Customer Impact

When a customer tries to pause an app that is running under the debugger, it may crash the app. This was very easy to reproduce using the sample provided in the issue.
CET + APC enabled caused a lot of issues and this is one of them. I think we should fix it because this is probably affecting a lot of customers that didn't open an issue because it's not easy to share a repro sample.

Regression

  • Yes (Works well on .NET 8)
  • No

Testing

Manually tested.

Risk

Medium risk, we are changing how we pause the threads in an Async Pause asked by the customer while debugging.

@Copilot Copilot AI review requested due to automatic review settings April 22, 2025 21:29
@ghost ghost added the area-VM-coreclr label Apr 22, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR backports changes to support special user mode APC handling in thread suspension and debugging paths.

  • Introduces new thread state flags (TS_SSToExitApcCall and TS_SSToExitApcCallDone) and helper methods to manage APC-related thread suspension.
  • Adds an overload for HandleSuspensionForInterruptedThread and updates debugger and controller logic to handle single-stepping out of APC calls.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/vm/threadsuspend.cpp Added APC handling in thread suspension, new method MarkForSuspensionAndWait, and overload for HandleSuspensionForInterruptedThread.
src/coreclr/vm/threads.h Updated thread state flags, friend declarations, and protected member methods.
src/coreclr/vm/dbginterface.h, debugger.h, debugger.cpp Introduced SingleStepToExitApcCall support for APC callbacks during debugging.
src/coreclr/debug/ee/controller.cpp Modified exception dispatch to manage APC exit using the new thread state flags.
Comments suppressed due to low confidence (1)

src/coreclr/vm/threadsuspend.cpp:4241

  • Ensure that the new FEATURE_SPECIAL_USER_MODE_APC code paths, including the APC exit handling, are adequately covered by regression tests to verify both normal and debugger-assisted scenarios.
#ifdef FEATURE_SPECIAL_USER_MODE_APC

Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@thaystg thaystg changed the title backport 111408 [release/9.0-staging] Apr 28, 2025
@thaystg thaystg changed the title [release/9.0-staging] [release/9.0-staging] Fix crash during Async Break when APC and CET are enabled Apr 28, 2025
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.

lgtm. we will take for consideration in 9.0.x

@jeffschwMSFT jeffschwMSFT added the Servicing-consider Issue for next servicing release review label Apr 28, 2025
@jeffschwMSFT jeffschwMSFT added this to the 9.0.x milestone Apr 28, 2025
@rbhanda rbhanda modified the milestones: 9.0.x, 9.0.6 Apr 29, 2025
@rbhanda rbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Apr 29, 2025
@vseanreesermsft vseanreesermsft added Servicing-consider Issue for next servicing release review and removed Servicing-consider Issue for next servicing release review labels May 2, 2025
@jozkee
Copy link
Member

jozkee commented May 7, 2025

@thaystg friendly reminder that code complete is on Monday May 12th (2:00 PM Pacific) for the June Release. If you'd like to get this change included in that release, please merge this PR before the deadline.

@thaystg
Copy link
Member Author

thaystg commented May 13, 2025

/ba know failures.

@thaystg
Copy link
Member Author

thaystg commented May 13, 2025

/ba-g unrelated failures

@thaystg
Copy link
Member Author

thaystg commented May 14, 2025

/ba known failures.

@thaystg thaystg merged commit 753e467 into dotnet:release/9.0-staging May 19, 2025
92 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants