Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
* Problem DOES occur when calling Stream.CopyTo(destination, bufferSize) and the destination stream is FileStream created with useAsync = true. Then there are some '\0' characters added in the destination FileStream.
* Problem DOES NOT occur when calling Stream.CopyTo(destination) without specified bufferSize. This is valid with the aforementioned details about the destination FileStream instance.
* Problem DOES NOT occur when using Microsoft.NET on Windows. I don't use Mono on Windows so I cannot provide information for that use case.
Following is an example which demonstrates the problem on:
* Ubuntu 14.04 LTS
* Mono 3.12.1
* MonoDevelop 5.7
public static class Program
public static void Main(string args)
StringBuilder dataBuilder = new StringBuilder();
for (int i = 0; i < 10000; ++i)
string expectedData = dataBuilder.ToString();
const string fileName = "test";
const bool useAsync = true;
const int bufferSize = 8192;
byte bytes = Encoding.Default.GetBytes(expectedData);
using (Stream dataStream = new MemoryStream(bytes))
using (Stream fileStream = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, useAsync))
// this works fine
// this fails
string actualData = File.ReadAllText(fileName);
Forgot to mention:
Problem DOES NOT occur when the destination FileStream is created with useAsync = false.
Fixed in Mono 4.0