-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[QUIC] Fix native crashes and heap corruption via "generated-like" interop #74669
Conversation
Tagging subscribers to this area: @dotnet/ncl |
Tagging subscribers to this area: @dotnet/ncl |
src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs
Outdated
Show resolved
Hide resolved
Can we also make the Also, since we are touching this, what about getting rid of the |
bc96468
to
0653eb5
Compare
0653eb5
to
72367aa
Compare
ThrowHelper.ThrowIfMsQuicError(MsQuicApi.Api.ApiTable->ConnectionOpen( | ||
MsQuicApi.Api.Registration.QuicHandle, | ||
ThrowHelper.ThrowIfMsQuicError(MsQuicApi.Api.ConnectionOpen( | ||
MsQuicApi.Api.Registration, | ||
&NativeCallback, | ||
(void*)GCHandle.ToIntPtr(context), | ||
&handle), |
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.
For the *Open methods we could make the wrapper use out MsQuicContextSafeHandle handle
parameter and construct the safe handle inside. What do you think?
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.
I'll try it out and see if makes sense. If yes, I'll work it in. I like the idea.
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.
This would be hard to make work automagically (tm) with source generators. But we could introduce manual helpers. Once again, postponing this for a follow up.
We're using it directly for
I'd love that, but as I'll the same reasoning as above, minimize churn and we can address this as a follow up. |
287b350
to
4667cef
Compare
4667cef
to
657639f
Compare
For follow up, filed: #75009 |
{ | ||
_sendBuffers.Reset(); | ||
_sendTcs.TrySetException(exception, final: true); | ||
if (_sendBuffers.Count > 0 && _sendBuffers.Buffers[0].Buffer != null) |
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.
I believe this will become a non-issue when #73691 is implemented. I made it a high prio issue for 8.0 since it seems more important now.
src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicSafeHandle.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.
LGTM, modulo existing comments
@@ -458,7 +458,6 @@ private unsafe int HandleEventConnected(ref CONNECTED_DATA data) | |||
_connectedTcs.TrySetResult(); | |||
return QUIC_STATUS_SUCCESS; | |||
} | |||
|
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.
Are these whitespace changes intentional?
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.
Yes, they are. Either we do have whitespace between Handle...
or not, but we should be consistent in all classes (Listener, Connection, Stream). I don't mind going either way, but I mind having them in Connection and nowhere else.
…terop (dotnet#74669) * Send buffers and handles crash fixes * Add generated-like interop * Apply PR feedback from dotnet#74611 * Change asserts * Feedback + moved native methods to their own file * PR feedback Co-authored-by: ManickaP <mapichov@microsoft.com>
…terop (#74669) (#75192) * Send buffers and handles crash fixes * Add generated-like interop * Apply PR feedback from #74611 * Change asserts * Feedback + moved native methods to their own file * PR feedback Co-authored-by: ManickaP <mapichov@microsoft.com> Co-authored-by: ManickaP <mapichov@microsoft.com>
Alternative to #74611
We should explore how to generate stuff like that in the future. Relevant PR: #65204
Fixes #72696