Bug 38538 - Sharing violation on FAT file systems on OSX with empty files
Summary: Sharing violation on FAT file systems on OSX with empty files
Status: NEW
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 44505 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-02-08 14:07 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2017-03-31 16:38 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Rolf Bjarne Kvinge [MSFT] 2016-02-08 14:07:32 UTC
Test case: https://gist.github.com/rolfbjarne/8c2df3a3c2a66af2d7ab

Run the test case when the current directory is on a fat-formatted volume on a usb drive.

> Unhandled Exception:
> System.IO.IOException: Sharing violation on path /Volumes/UNTITLED/bar
>   at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) <0x1a282d0 + 0x00708> in <filename unknown>:0 
>   at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, System.String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) <0x1a28200 + 0x0004f> in <filename unknown>:0 
>   at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
>   at System.IO.StreamWriter.CreateFile (System.String path, Boolean append, Boolean checkHost) <0x186ef50 + 0x000a4> in <filename unknown>:0 
>   at System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding, Int32 bufferSize, Boolean checkHost) <0x186ebd0 + 0x0006c> in <filename unknown>:0 
>   at System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding, Int32 bufferSize) <0x186eb80 + 0x00042> in <filename unknown>:0 
>   at System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding) <0x186eb30 + 0x0003b> in <filename unknown>:0 
>   at (wrapper remoting-invoke-with-check) System.IO.StreamWriter:.ctor (string,bool,System.Text.Encoding)
>   at System.IO.File.WriteAllText (System.String path, System.String contents, System.Text.Encoding encoding) <0x1a26530 + 0x0004a> in <filename unknown>:0 
>   at System.IO.File.WriteAllText (System.String path, System.String contents) <0x1a264f0 + 0x0002d> in <filename unknown>:0 
>   at Program.Main (System.String[] args) <0x6a1ee8 + 0x0004f> in <filename unknown>:0 

This happens because mono's sharing code doesn't account for the fact that zero-length fields on a fat file system has st_ino=999999999 [1] [2], so it treats two different files as identical.

[1] https://lists.gnu.org/archive/html/bug-m4/2014-05/msg00002.html
[2] http://www.gossamer-threads.com/lists/linux/kernel/56414
Comment 1 Rolf Bjarne Kvinge [MSFT] 2016-02-08 14:08:07 UTC
Correction: zero-length *files* have st_ino=999999999.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2016-09-22 15:44:33 UTC
*** Bug 44505 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.