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/9.0-staging] Use FLS detach as thread termination notification on windows. #110629

Open
wants to merge 7 commits into
base: release/9.0-staging
Choose a base branch
from

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Dec 11, 2024

Backport of #110589 to release/9.0-staging

/cc @VSadov

External threads that became known to the runtime (by running managed code via reverse PInvoke, for example) could cause a process-wide deadlock if the threads terminate during GC which happen to call an OS API that acquires the Loader Lock (launching background threads is just one example of such API).

Regression

  • Yes
  • No

The root cause was running thread termination routines directly or indirectly from DllMain. Thus the potential for the deadlock was present for a long time. However, the conditions for the deadlock are fairly narrow and the issue has not been known prior to the bug report.
It is likely that some changes in the timings around thread termination/creation made the deadlock more likely to happen in 9.0.

Testing

Regular testing.

This is a rare race condition with one of the requirements that a particular OS API is used.
Ensuring that the problematic API is no longer in use is more reliable validation than running tests,

Risk

Low.
The fix is essentially a switch to a different OS API/callback that does not run with Loader Lock acquired.
We have been using the same OS callback on NativeAOT for several releases.

Copy link
Contributor

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

// Parameters:
// thread - thread to detach
// Return:
// true if the thread was detached, false if there was no attached thread
Copy link
Member

Choose a reason for hiding this comment

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

Nit: just noticed the leftover comment when there was a return value.

@VSadov VSadov added Servicing-consider Issue for next servicing release review os-windows labels Dec 11, 2024
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

@leecow
Copy link
Member

leecow commented Dec 12, 2024

Check with customer to test private.

@VSadov
Copy link
Member

VSadov commented Dec 18, 2024

We see some issues with this in 10.0 See: #110801
Perhaps should wait for the resolution before merging this.

@jkotas jkotas added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) os-windows Servicing-consider Issue for next servicing release review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants