microsoft/Microsoft.IO.RecyclableMemoryStream

ArgumentNullException during Write

arman-microsoft opened this issue · 1 comments

Hey, I am non-deterministically getting an ArgumentNullException during a write.

Is this expected behavior if the stream is accidentally disposed? Or maybe a race condition?
Any insight would be appreciated.

ExpInfo(fullInfo->System.ArgumentNullException: Value cannot be null. (Parameter 'dst') at System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count) at Microsoft.IO.RecyclableMemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.IO.MemoryStream.WriteAsync(ReadOnlyMemory1 buffer, CancellationToken cancellationToken)`

Yes, this is likely happening because of a race condition somewhere in your code, and the stream is being disposed of during the write. You should be able to track this using ETW events and tracing through the stream in question.