[Mono-bugs] [Bug 665067] New: Doing 'create file' on opened file without file sharing causes data corruption.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jan 18 04:49:15 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=665067

https://bugzilla.novell.com/show_bug.cgi?id=665067#c0


           Summary: Doing 'create file' on opened file without file
                    sharing causes data corruption.
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: i686
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: alexander.ziegler at visiosens.de
         QAContact: mono-bugs at lists.ximian.com
          Found By: Component Test
           Blocker: ---


Created an attachment (id=408752)
 --> (http://bugzilla.novell.com/attachment.cgi?id=408752)
C# sample to reproduce the bug

1. Create a text file named "file.txt" with any text, e.g. "1234".

2. Open the file for appending and write data to it

..
FileStream fs1 = new FileStream("file.txt", FileMode.Append, 
                                FileAccess.Write,FileShare.None);
fs1.Write (System.Text.Encoding.ASCII.GetBytes ("2222"), 0, 4);
..

3. Try to create a file with the same name. This throws an IOException

..
FileStream fs2;
try
{
  fs2 = new FileStream("file.txt", FileMode.Create, 
                        FileAccess.Write,FileShare.None);

}
catch (IOException ex)
{
  fs1.Close ();
  Console.WriteLine ("Exception as expected!");
}
..

Actual Results:

- An IOException AS EXPECTED
- the file data is modified unexpectedly.
After running the program the file "file.txt" contains data:

  "\0\0\0\02222"

After appending the string "2222" the second access (create) overrides the
original
data at the beginning of the file. 

When a fs1.Flush() was inserted at the end of step 2 the behaviour changes.
Then the complete file is empty (zero length).

Expected Results:

- An IOException
- The following file data:

  "12342222"

A test under Windows 7/.NET 2.0 shows the desired results.

How often does this happen? 

Every time.

Additional Information:


System: Linux 2.6.32-27-generic-pae #49-Ubuntu SMP Thu Dec 2 00:07:52 UTC 2010
i686 GNU/Linux

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list