Repository navigation
Fix ProfileEnter when called on a foreign thread - #119327
Merged
janvorli merged 2 commits intoSep 4, 2025
Merged
Conversation
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 dotnet#115617
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a crash that occurs when ProfileEnter is called on a foreign thread (one that the runtime hasn't seen before), which can happen with UnmanagedCallersOnly marked methods. The fix removes an erroneous thread mode switch that was causing the crash.
- Removes the problematic
GCX_COOP_THREAD_EXISTS(GET_THREAD())call that crashes on foreign threads - Changes from
HCIMPL2_RAWtoHCIMPL2macro usage to properly handle thread setup
Contributor
|
Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag |
jkotas
reviewed
Sep 3, 2025
jkotas
approved these changes
Sep 3, 2025
noahfalk
approved these changes
Sep 4, 2025
Member
Author
|
/backport to release/10.0 |
Contributor
|
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/17461109329 |
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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