C# Fix issues with socket buffer sizes#276
Conversation
|
I added another commit since it's so near by. Turns out the C# garbage collector can move the byte[] memory and that the unsafe memory call must always be accompanied by pinning the memory so the garbage collector knows not to move that block. See the comment on this documentation: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.unsafeaddrofpinnedarrayelement?view=net-8.0 The likely symptoms are that the memory returned is suddenly all zeroes if it's been cleared or that suddenly the memory turns from expected values to zeroes for the rest of the data. I did not see a situation where it was moved to random or non-zeroed memory. I believe it's ok to call this multiple times and here rather than in the user code, but I'm not quite sure. |
|
|
Attempt for #257 @joseph-henry