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)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 38538 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

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. ***