-
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
Socket connect with payload via SocketAsyncEventArgs fails #79654
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDescriptionAppears to have been introduced here /cc @stephentoub
This is because the code sends Proposed fix: pass This API should probably be passing Reproduction StepsRequires preview CLR? (note I haven't bothered with a server here; not needed for demonstration) using var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var saea = new SocketAsyncEventArgs();
saea.RemoteEndPoint = new IPEndPoint(IPAddress.Loopback, 42);
saea.SetBuffer(new byte[42]); // <== the presence of the buffer is what triggers the failure
// normally we would configure a callback, check the bool etc - not needed to demonstrate failure
client.ConnectAsync(saea); // BOOM!!! Expected behaviorConnects and transmits Actual behaviorFaults with invalid address Regression?Works in CLR7 Known Workaroundsconnect without a buffer, then send afterwards ConfigurationNo response Other informationNo response
|
Is this essentially #1476? AFAIK that was never fully implemented and supported. But I assume the break was not intentional so we should look into it. |
@wfurt isn't TFO more than just "data in SYN"?
I would assume This is definitely platform-specific behavior though, on Unix the buffer is ignored in all versions. |
"connects successfully without sending the buffer" would also be an acceptable outcome, if that is the documented and intended behaviour; it is odd that it is different between platforms; "fails in an obscure way if a buffer is set": not so much |
@antonfirsov fortunately it is somewhat discoverable by checking the |
Reopening, to track backport, this is a regression. |
Backport PR #79866 has been merged. |
Description
Appears to have been introduced here with the removal of the early pin /cc @stephentoub
WSAConnect
supports connect+transmit, which is supported inSocketAsyncEventArgs
, and implemented inDoOperationConnectEx
- however, a critical bug stops it working when a buffer is specified, faulting with "The system detected an invalid pointer address in attempting to use a pointer argument in a call.".This is because the code sends
(IntPtr)((byte*)_singleBufferHandle.Pointer + _offset),
as the payload pointer, but_singleBufferHandle
is not initialized until afterConnectEx
, inProcessIOCPResult
(to avoid pins in the synchronous case).Proposed fix: pass
bufferPtr
instead.This API should probably be passing
bufferPtr
here, which is the same address viafixed
(fine for the synchronous case, and ends up pinned while fixed in the async case)Reproduction Steps
Fails on
net7.0
(note I haven't bothered with a server here; not needed for demonstration)
Expected behavior
Connects and transmits; specifically,
ConnectAsync
should returntrue
(pending), or should reportfalse
(complete) with a suitableSocketError
Actual behavior
ConnectAsync
reportsfalse
(complete) withSocketError
asFault
Regression?
Yes; works in
net6.0
Known Workarounds
connect without a buffer, then send afterwards
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: