[Mono-bugs] [Bug 61131][Nor] New - System.IO.FileStream behaves strangely on large files.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 3 Jul 2004 15:29:18 -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 alfius@freemail.gr.

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

--- shadow/61131	2004-07-03 15:29:18.000000000 -0400
+++ shadow/61131.tmp.9701	2004-07-03 15:29:18.000000000 -0400
@@ -0,0 +1,141 @@
+Bug#: 61131
+Product: Mono: Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: alfius@freemail.gr               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: System.IO.FileStream behaves strangely on large files.
+
+I have observed some strange behaviour while using a FileStream to
+access large files (>4GB).
+
+Steps to reproduce the problem:
+1. Create a large file.
+
+For example I have a large file 'bigfile':
+-rw-r--r--    1 alf      users    4898967552 Jul  1 00:44 bigfile
+
+2. compile the following program
+
+---Code start------------------------------------
+
+using System.IO;
+using System;
+
+class btest {
+
+    public static void Main() 
+    {
+        FileStream fs=new FileStream("bigfile", FileMode.Open,
+FileAccess.Read);
+        
+        Console.WriteLine("Offset 1: {0:x}", fs.Seek(0x1000000,
+SeekOrigin.Begin));
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+        Console.WriteLine("Offset 2: {0:x}", fs.Seek(0x100,
+SeekOrigin.Begin));     
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+        Console.WriteLine("Offset 3: {0:x}", fs.Seek(0x7fffffff,
+SeekOrigin.Begin));
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+        Console.WriteLine("Offset 4: {0:x}", fs.Seek(0x80000000,
+SeekOrigin.Begin));
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+        Console.WriteLine("Offset 5: {0:x}", fs.Seek(0xf0000000,
+SeekOrigin.Begin));     
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+        Console.WriteLine("Offset 6: {0:x}", fs.Seek(0xfffffffe,
+SeekOrigin.Begin));     
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+        Console.WriteLine("Offset 7: {0:x}", fs.Seek(0x100000000,
+SeekOrigin.Begin));     
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+        Console.WriteLine("Offset 8: {0:x}", fs.Seek(0x1234555,
+SeekOrigin.Begin));     
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+        Console.WriteLine("Offset 9: {0:x}", fs.Seek(0x100000000,
+SeekOrigin.Begin));     
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+        
+        string[] files=Directory.GetFiles(".","*.cs");
+        
+        Console.WriteLine("Offset 10: {0:x}", fs.Seek(0x1234555,
+SeekOrigin.Begin));     
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+        Console.WriteLine("Offset 11: {0:x}", fs.Seek(0x100000000,
+SeekOrigin.Begin));     
+        Console.WriteLine("Value {0:x}", fs.ReadByte());
+
+        Console.WriteLine("Offset 12: {0:x}", fs.Seek(0xf0000000,
+SeekOrigin.Begin));     
+        Console.WriteLine("Value {0:x}", fs.ReadByte());    
+    }
+
+}
+
+---Code End------------------------------------------------
+
+
+Actual Results:
+---Results Start-------------------------------------------
+$ mcs btest.cs
+Compilation succeeded
+$ mono --debug btest.exe
+Offset 1: 1000000
+Value 11
+Offset 2: 100
+Value b4
+Offset 3: 7fffffff
+Value e0
+Offset 4: 80000000
+Value 10
+Offset 5: ffffffff
+Value ae
+Offset 6: ffffffff
+Value fd
+Offset 7: 100000000
+Value c0
+Offset 8: 1234555
+Value c4
+Offset 9: 100000000
+Value f5
+Offset 10: 1234555
+Value c4
+Offset 11: 100000000
+Value f5
+
+Unhandled Exception: System.IO.IOException: Win32 IO returned
+ERROR_NO_MORE_FILES. Path: bigfile
+in [0x00111] (at /cvs/mcs/class/corlib/System.IO/FileStream.cs:707)
+System.IO.FileStream:Seek (long,System.IO.SeekOrigin)
+in <0x005f1> btest:Main ()
+---Results End-------------------------------------------
+
+
+Expected Results:
+
+First of all when trying to access offsets between 0x80000000-0xffffffff
+I some time get that the offset is 0xffffffff. Also when trying to
+access an offset above 0x80000000 twice (eg offset 7,11) the results I
+get from ReadByte() are not always the same.
+
+Directory.GetFiles() seems to have a strange effect. After calling it,
+all accesses that would be "invalid" before calling it (would return
+0xffffffff) throw an apparently irrelevant exception.
+
+
+How often does this happen? 
+Always
+
+Additional Information:
+This happens on mono beta 2. I haven't tested it on mono 1.0.