-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Mitigation for a GC Stress race after an inline pinvoke #38246
Conversation
In the post-call part of a pinvoke inline call frame, it's not safe to start a stress mode GC in the window between checking `g_TrapReturningThreads` and the call to `CORINFO_HELP_STOP_FOR_GC`. The call instruction is already getting special treatement, but there may be other instructions between the check and call. Instead of trying to pattern match them all, suppress GC stress if `g_TrapReturningThreads` is true, the thread is in cooperative mode, and there's an active inline call frame. Closes dotnet#37236.
GC count looks comparable before/after fix:
|
You can try to delete all special-casing of |
Thank you! |
I was thinking the same thing. Will try it as a follow-up. |
We shouldn't need this anymore as the case it protects against should be covered by the new check added in dotnet#38246.
In the post-call part of a pinvoke inline call frame, it's not safe
to start a stress mode GC in the window between checking
g_TrapReturningThreads
and the call toCORINFO_HELP_STOP_FOR_GC
.The call instruction is already getting special treatement, but there may
be other instructions between the check and call. Instead of trying
to pattern match them all, suppress GC stress if
g_TrapReturningThreads
is true, the thread is in cooperative mode, and there's an active inline
call frame.
Closes #37236.