Skip to content

Don't create a COM weak reference if the object is an aggregated COMWrappers RCW. - #61267

Merged
jkoritzinsky merged 3 commits into
dotnet:mainfrom
jkoritzinsky:no-weakref-agg
Nov 6, 2021
Merged

Don't create a COM weak reference if the object is an aggregated COMWrappers RCW.#61267
jkoritzinsky merged 3 commits into
dotnet:mainfrom
jkoritzinsky:no-weakref-agg

Conversation

@jkoritzinsky

@jkoritzinskyjkoritzinsky commented Nov 5, 2021

Copy link
Copy Markdown
Member

This prevents us from trying to re-create a managed object that is a user-defined object deriving from an RCW type from a COM IWeakReference (which fails).

The included test crashes on main with an AV and passes with the changes in this PR.

Fixesmicrosoft/CsWinRT#1025

Comment threadsrc/coreclr/vm/interoplibinterface_comwrappers.cpp Outdated
Comment threadsrc/coreclr/vm/interoplibinterface_comwrappers.cpp Outdated
Comment threadsrc/tests/Interop/COM/ComWrappers/WeakReference/WeakReferenceTest.cs Outdated
Comment threadsrc/coreclr/vm/interoplibinterface_comwrappers.cpp Outdated
Comment threadsrc/tests/Interop/COM/ComWrappers/WeakReference/WeakReferenceTest.cs Outdated
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

@jkoritzinsky Let's start the port to .NET 6 ASAP.

@jkoritzinsky

Copy link
Copy Markdown
MemberAuthor

/backport to release/6.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1429642390

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Taking a WeakReference to a C# object that inherits a native WinRT object crashes the app.

2 participants

@jkoritzinsky@AaronRobinsonMSFT