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

Don't block non-blittable pointer types in P/Invokes. #1866

Merged

Conversation

jkoritzinsky
Copy link
Member

Don't block non-blittable pointer types in P/Invokes. If you're using pointers in interop you're already using unsafe code so we're going to assume you know what you're doing. C# won't let you form a pointer to a reference, so there's no risk of passing an object reference directly to native unless you're writing IL directly.

Fixes dotnet/coreclr#27800

Don't block non-blittable pointer types in P/Invokes. If you're using pointers in interop you're already using unsafe code so we're going to assume you know what you're doing. C# won't let you form a pointer to a reference, so there's no risk of passing an object reference directly to native unless you're writing IL directly.

Fixes dotnet/coreclr#27800
@jkotas
Copy link
Member

jkotas commented Jan 17, 2020

Do any tests need to be added or updated?

@jkotas
Copy link
Member

jkotas commented Jan 17, 2020

Could you please make the same fix in MarshalHelpers.cs (look for 27800).

@jkoritzinsky
Copy link
Member Author

I'll add a test with a bool* to validate that we allow this now. I don't believe we currently have any negative tests for this.

@ghost
Copy link

ghost commented Jan 17, 2020

Hello @jkoritzinsky!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@jkoritzinsky jkoritzinsky merged commit 53e8fea into dotnet:master Jan 23, 2020
@jkoritzinsky jkoritzinsky deleted the allow-nonblittable-pointers-interop branch January 23, 2020 00:22
MichalStrehovsky added a commit that referenced this pull request Jan 23, 2020
Fixes #483. Structs with pointer-typed fields are blittable.

After #1866 we no longer have to worry about the recursion because the code path that recursed into pointed-to types was deleted.
MichalStrehovsky added a commit that referenced this pull request Jan 23, 2020
Fixes #483. Structs with pointer-typed fields are blittable.

After #1866 we no longer have to worry about the recursion because the code path that recursed into pointed-to types was deleted.
@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
Sign up for free to 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.

3 participants