-
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
Exit the lock before we call into user code and handle losing the race for the RCW table #110828
Conversation
…e for the RCW table.
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
1. Register that we've created a managed object as a wrapper for a COM object first (equivalent to ExtObjCxtCache in CoreCLR) 2. Register the NativeObjectWrapper for lifetime management (equivalent to the sync-block interop info in CoreCLR). This ensures that we have the same behavior as CoreCLR.
Tests for this specific deadlock are still TODO, but I've reorganized the code for the NativeAOT ComWrappers implementation to match the same order of logic as the CoreCLR implementation and encapsulated each step into separate helper functions (which also helped significantly clarify lock usage). |
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
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.
Thank you for adding all the comments!! 😄
Left a few more notes.
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
… the "RCW address -> wrapper" cache. Use a WeakReference as we don't want to keep the wrapper alive any longer with it being in the cache.
…here's only ever one NativeObjectWrapper we try to register, the one that's in the RCW cache
Validated that the ComWrappers tests pass locally and added a test for the deadlock. This is ready for review! |
Co-authored-by: Sergio Pedri <[email protected]>
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
5b92f86
to
b46e3a8
Compare
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
@jkoritzinsky Can you please run GCStress locally? Ideally we'd also include some amount of JITStress too. I'm also fine kicking off the legs that run too. |
Do we have GCStress support for NativeAOT? |
@jkoritzinsky Oh, right. I think we do, but we don't have a CI for it. @MichalStrehovsky Do we have a way to run GCStress on local native AOT? |
There is no GC stress for native AOT. |
/azp run runtime-nativeaot-outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
Not exactly the same (although @EgorBo said it's kinda close enough? 😅), I've added an option in the Microsoft Store to simulate GC stress (I basically just spawn a thread that just spams |
NativeAOT outerloop failures are unrelated. Can I get one more review pass? |
…e for the RCW table (dotnet#110828)
I tested with the Microsoft Store and everything seems to work fine:
I used the Store for a while, including closing and launching it a few times, with and without our "GC stress" mode enabled as well (which creates a thread that just spams Could we backport this one too? I think it should be our last blocker from the NAOT side for shipping 😄 |
/backport to release/9.0-staging |
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/12654501932 |
Fixes #110823