-
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
Avoid handing out duplicate CORINFO_MODULE_STRUCT_*
handles
#94082
Conversation
RyuJIT depends on never seeing two different `CORINFO_MODULE_STRUCT` for the same thing. Fixes dotnet#93843.
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsRyuJIT depends on never seeing two different Fixes #93843. Cc @dotnet/ilc-contrib
|
} | ||
|
||
private Dictionary<object, IntPtr> _objectToHandle = new Dictionary<object, IntPtr>(new JitObjectComparer()); | ||
private Dictionary<MethodDesc, IntPtr> _methodILScopeToHandle = new Dictionary<MethodDesc, IntPtr>(new JitObjectComparer()); |
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.
Just for my education - this is a per-method cache, as in, we're going to clear it after each method compilation. And JIT doesn't maintain any state between methods either, right?
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.
Yes, it's per method and there's not supposed to be extra state on the JIT side either.
Where is this dependency exactly? |
Per #93843 (comment) it's in GenTreeStrCon equality. I think it's this: runtime/src/coreclr/jit/gentree.cpp Lines 2704 to 2710 in 2dc7c31
|
This condition is not a precise check to validate whether two string literals are going produce same string object. It is going to miss on string literals from different modules with JIT, and it is going to miss on string literals from different methods with AOT/R2R. It may be better to abstract this comparison via JIT/EE interface, so that it can be more precise. In general, JIT depending on module handle equality seems to be an anti-pattern. |
That was something I considered. It has the following drawbacks:
(As I said in the issue) I don't know what the "right" fix here is. This change seems like a practical option. |
I agree that this change is a practical option. It will work ok as long as nothing depends on the comparison being precise. |
@dotnet/jit-contrib anyone else has an opinion about this fix? We're working around RyuJIT making assumptions about If not, I'll merge this, but it is quite fragile. A more robust fix on the driver side would be to never purge the ILProvider cache and eat the memory overhead (essentially turn a cache into a memory leak). That one is obviously not great either. |
This fix looks good to me. I agree with @SingleAccretion about the concerns for |
/backport to release/8.0-staging |
Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/7057987064 |
RyuJIT depends on never seeing two different
CORINFO_MODULE_STRUCT
for the same thing.Fixes #93843.
Cc @dotnet/ilc-contrib