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

[QUIC] Fix native crashes and heap corruption via "generated-like" interop #74669

Merged
merged 6 commits into from
Sep 6, 2022

Conversation

CarnaViire
Copy link
Member

Alternative to #74611

We should explore how to generate stuff like that in the future. Relevant PR: #65204

Fixes #72696

@ghost
Copy link

ghost commented Aug 26, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Alternative to #74611

We should explore how to generate stuff like that in the future. Relevant PR: #65204

Fixes #72696

Author: CarnaViire
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@ghost
Copy link

ghost commented Aug 26, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Alternative to #74611

We should explore how to generate stuff like that in the future. Relevant PR: #65204

Fixes #72696

Author: CarnaViire
Assignees: CarnaViire
Labels:

area-System.Net.Quic

Milestone: -

@rzikm
Copy link
Member

rzikm commented Aug 29, 2022

Can we also make the MsQuicApi.Api.ApiTable object private so it forces us to use the wrappers?

Also, since we are touching this, what about getting rid of the .Api. in the middle by making the methods static on MsQuicApi?

ThrowHelper.ThrowIfMsQuicError(MsQuicApi.Api.ApiTable->ConnectionOpen(
MsQuicApi.Api.Registration.QuicHandle,
ThrowHelper.ThrowIfMsQuicError(MsQuicApi.Api.ConnectionOpen(
MsQuicApi.Api.Registration,
&NativeCallback,
(void*)GCHandle.ToIntPtr(context),
&handle),
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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.

@ManickaP
Copy link
Member

ManickaP commented Sep 2, 2022

Can we also make the MsQuicApi.Api.ApiTable object private so it forces us to use the wrappers?

We're using it directly for Close... methods. It's doable though, but I'm hesitant to do this change in this PR (increased churn, we want to backport).

Also, since we are touching this, what about getting rid of the .Api. in the middle by making the methods static on MsQuicApi?

I'd love that, but as I'll the same reasoning as above, minimize churn and we can address this as a follow up.

@ManickaP
Copy link
Member

ManickaP commented Sep 2, 2022

For follow up, filed: #75009

{
_sendBuffers.Reset();
_sendTcs.TrySetException(exception, final: true);
if (_sendBuffers.Count > 0 && _sendBuffers.Buffers[0].Buffer != null)
Copy link
Member

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.

Copy link
Member

@rzikm rzikm left a 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;
}

Copy link
Member

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?

Copy link
Member

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.

@CarnaViire CarnaViire deleted the quic-crash-fix-v2 branch September 6, 2022 18:09
@karelz karelz added this to the 8.0.0 milestone Sep 7, 2022
CarnaViire added a commit to CarnaViire/runtime that referenced this pull request Sep 7, 2022
…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>
carlossanlop pushed a commit that referenced this pull request Sep 8, 2022
…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>
@ghost ghost locked as resolved and limited conversation to collaborators Oct 7, 2022
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.

[HTTP/3] SIGABRT in stress tests
6 participants