-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 DynamicInvokeMethodThunk hash code collisions #103274
Conversation
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.
Alternative fix would be to go back to how we used to compute the name of these methods (it wasn't always a constant string), but I don't have a strong opinion. We don't otherwise override ComputeHashCode
anywhere else. It's only virtual because of instantiated methods:
runtime/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs
Lines 493 to 495 in eb8f54d
/// <summary> | |
/// Compute HashCode. Should only be overridden by a MethodDesc that represents an instantiated method. | |
/// </summary> |
Delete this comment since it is not valid anymore? |
I would like to keep some comment there. There are runtime dependencies on the hash code both in NativeAOT and R2R. For NativeAOT it should mostly link to the same code in Any suggestion for wording? |
It might be easier to just add some suffix to the Name/DiagnosticName (e.g. number of parameters) so that we avert at least some of the collisions, drop the override, and call it good enough. |
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.
Any suggestion for wording?
This hashcode is persisted into the image. The algorithm to compute it must be in sync with the one used at runtime.
It might be easier to just add some suffix to the Name/DiagnosticName (e.g. number of parameters)
Number of parameters is going to reduce the collisions like 3x (a lot of methods take one or two arguments). It would be still leaving a lot on the table.
src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs
Show resolved
Hide resolved
…odThunk.cs Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Thank you! |
Fixes #103070
Let's see the CI if it breaks anything.