-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix ProfileEnter when called on a foreign thread #119327
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
Fix ProfileEnter when called on a foreign thread #119327
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
There was a problem hiding this 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 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
|
Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag |
noahfalk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @janvorli!
|
/backport to release/10.0 |
|
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/17461109329 |
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