[Mono-bugs] [Bug 75526][Nor] Changed - StreamReader blocks on reading too much

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Jul 31 17:55:53 EDT 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bmaurer at users.sf.net.

http://bugzilla.ximian.com/show_bug.cgi?id=75526

--- shadow/75526	2005-07-13 12:58:14.000000000 -0400
+++ shadow/75526.tmp.26143	2005-07-31 17:55:53.000000000 -0400
@@ -3,21 +3,21 @@
 Version: 1.1
 OS: All
 OS Details: 
 Status: NEW   
 Resolution: 
 Severity: Unknown
-Priority: Wishlist
+Priority: Normal
 Component: CORLIB
 AssignedTo: mono-bugs at ximian.com                            
 ReportedBy: gnauck at ag-software.de               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
-Summary: StreamReader.Read(char[], int, int)
+Summary: StreamReader blocks on reading too much
 
 while debugging my library under windows i stumbled of following.
 I create a new StreamReader from a NetworkStream for parsing Xml.
 
 StreamReader sr = new StreamReader(myTcpClient.GetStream());
 
@@ -37,6 +37,50 @@
 in the Stream it blocks on MONO and MS .NET which is OK.
 
 Alex
 
 ------- Additional Comments From miguel at ximian.com  2005-07-13 12:58 -------
 Please post a complete example.
+
+------- Additional Comments From bmaurer at users.sf.net  2005-07-31 17:55 -------
+Actually, this is really easy to reproduce without even touching
+network stream:
+
+using System.IO;
+using System;
+
+class X : MemoryStream {
+	public override int Read (byte [] buffer, int offset, int count)
+	{
+		Console.WriteLine ("Read");
+		buffer [offset + 0] = (byte) 'a';
+		buffer [offset + 1] = (byte) 'b';
+		return 2;
+	}
+
+	static void Main ()
+	{
+		TextReader tr = new StreamReader (new X ());
+		Console.WriteLine (tr.Read (new char [10], 0, 10));
+	}	
+}
+
+Here, we have a custom stream impl that always reads 2 bytes. On the
+current impl, we get:
+
+[benm at omega ~]$ mono zzz.exe
+Read
+Read
+Read
+Read
+Read
+10
+
+Thus, it trys to read until enough data.
+
+However, microsoft's impl gives
+
+Read
+2
+
+After the first read it gives up. If I changed my stream impl to block
+after the first read, the problem the reporter experienced would happen


More information about the mono-bugs mailing list