Skip to content

Copy send buffer within Socket.BeginSend{,To}.

Brendan McGrath requested to merge redmcg/mono:bm_cw_19982_socket into main

This allows the socket to own its own buffer during the async send operation. This prevents an application from overwriting the provided data prior to completion of the send.

This fixes multiplayer in Terraria when ran with wine-mono. The game makes multiple successive calls to Socket.BeginSend. In each call it is using the same buffer, but replacing the data. Because the async operation has no ownership of the buffer, it sends what is in the buffer at the time of the transmission (which is usually not the data at the time of the method call).

I am able to replicate this with the attached program: SocketTest.cs.

Simply running this with mono SocketTest.exe after running nc -l 7777 will produce World!World! when Hello\nWorld!\n is expected. Running this on Windows (under .NET Framework 4.x) produces the expected result.

Edited by Brendan McGrath

Merge request reports

Loading