Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Sep 4, 2025

Backport of #119327 to release/10.0

/cc @janvorli

Customer Impact

When customers run a .NET application under a profiler and the application code has methods marked by the [UnmanagedCallersOnly] attribute that are called from foreign threads, the runtime crashes during the profiling.

Regression - introduced in the .NET

Testing

CI testing

Risk

Low, it removes a call that has no effect when the profiled method is not marked as [UnmanagedCallersOnly] and crashes in the problematic call. The switch to GC cooperative mode that was done by that calls occurs later in the ProfileEnter.

When ProfileEnter is called on a foreign thread that the runtime has not
seen yet, which can happen for UnmanagedCallersOnly marked methods,
it crashes in the GCX_COOP_THREAD_EXISTS(GET_THREAD()); That was left in
by accident in my change I've made a long time ago and should not be
there.
This change removes that switch, we switch to cooperative mode later in
the ProfileEnter and setup the thread for runtime before that.

Close #115617
@janvorli janvorli self-assigned this Sep 4, 2025
@janvorli janvorli added this to the 10.0.0 milestone Sep 4, 2025
@dotnet-policy-service
Copy link
Contributor

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

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. please get a code review. we can merge when ready

@jeffschwMSFT jeffschwMSFT added the Servicing-approved Approved for servicing release label Sep 4, 2025
@jeffschwMSFT
Copy link
Member

@janvorli can you take a look at the ci failures?

@janvorli
Copy link
Member

janvorli commented Sep 8, 2025

@jeffschwMSFT the test was killed due to the fact that it uses too much memory (@simonrozsival helped me to decipher that). I'll try to re-run the test, but it is not related to my change in any way.

@janvorli
Copy link
Member

@agocke can you please merge it in?

@jeffschwMSFT jeffschwMSFT merged commit 043fcd5 into release/10.0 Sep 11, 2025
101 of 103 checks passed
@jkotas jkotas deleted the backport/pr-119327-to-release/10.0 branch September 22, 2025 23:29
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-VM-coreclr Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants