Skip to content
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 resolving IWeakReference from different context #1301

Merged
merged 2 commits into from
Mar 16, 2023

Conversation

manodasanW
Copy link
Member

Taking the findings from #1300 and putting in a slightly different fix. Reusing the test case from it.

For weak references, when they are accessed from a different context, we use the agile reference to resolve a pointer in the current context. This ptr doesn't necessarily point to the same interface / vtbl from when we initially created it. Instead, it can point to IUnknown and can cause unexpected issues when we call it with the assumption it is the IWeakReference vftbl. This fix ensures we retrieve the pointer on the right context by making sure IObjectReference is aware of the IID it was initially created for which means it can use it when resolving the agile reference.

… can end up treating IUnknown as the IWeakReference interface
@manodasanW manodasanW requested a review from jlaanstra March 15, 2023 19:16
@manodasanW manodasanW merged commit 86d7976 into master Mar 16, 2023
@manodasanW manodasanW deleted the manodasanw/fixweakreference branch March 16, 2023 00:14
dongle-the-gadget pushed a commit to dongle-the-gadget/CsWinRT that referenced this pull request Jul 29, 2023
* Fix issue with weak reference when marshaled across contexts where we can end up treating IUnknown as the IWeakReference interface

* Slight refactor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants