[release/9.0-staging] Backport "Use FLS detach callback as a thread termination notification. Another try." by VSadov · Pull Request #113055 · dotnet/runtime

@VSadov @jkotas

… try. (dotnet#112809)

* Use FLS detach as thread termination notification on windows.

* use _ASSERTE_ALL_BUILDS

* one more case

* InitFlsSlot throws per convention used in threading initialization

* OsDetachThread could be void

* Update src/coreclr/vm/ceemain.cpp

* ensure CoInitialize

* Asserts to fail deterministically.

* comments

* scope the failfast to Windows and tweak the comments a bit.

* better assert

* Apply suggestions from code review

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* Undo unnecessary finalizer thread changes

* reverse the failfast condition

* handle destruction of unattached threads

* PR feedback

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* Update src/coreclr/vm/ceemain.cpp

* set g_fComStarted as soon as we call CoInitialize

* Naming nit

* fix a typpo + better comment

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

AI review requested due to automatic review settings

March 3, 2025 03:21

jeffschwMSFT

@VSadov VSadov removed the NO-MERGE

The PR is not ready for merge yet (see discussion for detailed reasons)

label

Mar 19, 2025

@VSadov VSadov deleted the backport112809 branch

March 19, 2025 00:35

This was referenced

Apr 3, 2025