[Mono-bugs] [Bug 62484][Nor] New - unexpected exception thrown, seemingly due to file size using StreamWriter

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 4 Aug 2004 23:06:34 -0400 (EDT)


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 mmmurf@gmail.com.

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

--- shadow/62484	2004-08-04 23:06:34.000000000 -0400
+++ shadow/62484.tmp.3686	2004-08-04 23:06:34.000000000 -0400
@@ -0,0 +1,117 @@
+Bug#: 62484
+Product: Mono: Runtime
+Version: unspecified
+OS: other
+OS Details: gentoo linux w/ mono 1.0 ebuild
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mmmurf@gmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: unexpected exception thrown, seemingly due to file size using StreamWriter
+
+Description of Problem:
+
+Writing to StreamWriter results in strange error after a while, for no
+apparent reason.
+
+Steps to reproduce the problem:
+1. Create a StreamWriter and write data to it
+2. Keep writing data until you receive the error below
+3. When in append mode, one error occurs, and when append==false, another
+one does.
+
+
+Actual Results:
+
+In append mode:
+Unhandled Exception: System.IO.IOException: Can't seek back over
+pre-existing data in append mode
+in <0x001d8> System.IO.FileStream:Seek (long,System.IO.SeekOrigin)
+in <0x000c4> System.IO.FileStream:set_Position (long)
+in <0x00255> System.IO.StreamWriter:.ctor
+(string,bool,System.Text.Encoding,int)
+in <0x00030> System.IO.StreamWriter:.ctor (string,bool)
+in <0x0006b> (wrapper remoting-invoke-with-check)
+System.IO.StreamWriter:.ctor (string,bool)
+in <0x0004d> ddr.UDSplitter:Main (string[])
+
+ this happens even though the code is just telling it to append in a very
+simple fashion.
+
+When trying to create a file, without append, when the file grows too large
+the following error occurs:
+
+Unhandled Exception: System.IO.FileNotFoundException: Could not find file
+"D.out"
+in <0x00083> System.IO.FileStream:FlushBuffer ()
+in <0x0004f> (wrapper remoting-invoke-with-check)
+System.IO.FileStream:FlushBuffer ()
+in <0x00121> System.IO.FileStream:WriteInternal (byte[],int,int)
+in <0x00073> (wrapper remoting-invoke-with-check)
+System.IO.FileStream:WriteInternal (byte[],int,int)
+in <0x00198> System.IO.FileStream:Write (byte[],int,int)
+in <0x0006c> System.IO.StreamWriter:FlushBytes ()
+in <0x0004f> (wrapper remoting-invoke-with-check)
+System.IO.StreamWriter:FlushBytes ()
+in <0x00024> System.IO.StreamWriter:Decode ()
+in <0x0004f> (wrapper remoting-invoke-with-check)
+System.IO.StreamWriter:Decode ()
+in <0x00036> System.IO.StreamWriter:LowLevelWrite (char[],int,int)
+in <0x00073> (wrapper remoting-invoke-with-check)
+System.IO.StreamWriter:LowLevelWrite (char[],int,int)
+in <0x00071> System.IO.StreamWriter:Write (string)
+in <0x0000e> System.IO.TextWriter:WriteLine (string)
+in <0x000c1> ddr.UDSplitter:ProcessFile (string)
+in <0x000a6> ddr.UDSplitter:Main (string[])
+
+
+Expected Results:
+
+It should just keep adding to the file.  The code is supposed to take a
+file, where rows either start with a U or a D, and write rows with a D to
+D.cav and those with a U to U.cav... It writes a large amount of data
+properly and then suddenly displays the second error above.
+
+How often does this happen? 
+
+Every time the program is run
+
+Additional Information:
+
+The method that throws the exception is below:
+
+        public static void ProcessFile(string filename){
+
+        using (StreamReader sr = new StreamReader(filename))
+            {
+                String line;
+                // Process the file until the end of
+                // the file is reached.
+                while ((line = sr.ReadLine()) != null)
+                {
+
+                    if(line.Substring(0,5).IndexOf('U')!=-1){
+                        // write U
+                        UWriter.WriteLine(line);
+                        //Console.WriteLine("found a U");
+                        ucount++;
+                    }else{
+                        // write D
+                        DWriter.WriteLine(line);
+                        //Console.WriteLine("found a D");
+                        dcount++;
+                    }
+
+
+                }
+            }
+
+
+    }