-
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
ComInterfaceGenerator generates cleanup stage for stateless marshalled parameters when it shouldn't #85795
Comments
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsParameters marshalled by stateless marshallers are being freed in too many scenarios. They should only be freed in unmanaged to managed ref scenarios (on the pointer that was passed in, not the value that is returned at the end of the method. In and Out parameters should not be cleaned up.
|
For stateful marshallers specifically, they may also be tracking additional state for an unmanaged->managed in/out/ref scenario that needs to be freed in addition to/instead of the unmanaged value. |
Refactor the elements marshalling logic to split out space allocation and source/destination span construction from the elements marshalling logic. Pull out the element marshalling logic to a common base class and separate it out from the actual marshalling strategies. This refactoring is required to provide customization points to correctly fix dotnet#85795. I've validated that this change is a zero-diff change on all of the generated code for the LibraryImportGenerator integration tests.
…ansfered to the callee Fixes dotnet#85795
Parameters marshalled by stateless marshallers are being freed in too many scenarios. They should only be freed in unmanaged to managed ref scenarios (on the pointer that was passed in, not the value that is returned at the end of the method. In and Out parameters should not be cleaned up. Stateful marshallers can have free called on them as they can know which MarshalMode they are in and decide to actually free the underlying memory or not.
The text was updated successfully, but these errors were encountered: