Bugzilla – Bug 318050
Lock violation writing to file on SMB share on Mac OS X
Last modified: 2010-03-18 18:10:14 UTC
---- Reported by brion@pobox.com 2005-05-21 02:14:19 MST ---- Description of Problem: Writing to a file on a mounted SMB share fails with a lock violation exception on Mac OS X. Steps to reproduce the problem: 1. Mount a writable SMB share from a Windows or Samba server 2. Open a file for writing on the share (File.CreateText, File.OpenWrite etc) 3. Write to the file 4. Flush or close the file. Actual Results: The file is created ok, but when trying to flush actual written data an exception is thrown and the file stays empty: Unhandled Exception: System.IO.IOException: Lock violation on path testfile.txt in <0x0013c> System.IO.FileStream:FlushBuffer () in (wrapper remoting-invoke-with-check) System.IO.FileStream:FlushBuffer () in <0x0002c> System.IO.FileStream:Flush () in <0x00060> System.IO.StreamWriter:Flush () in <0x00050> System.IO.StreamWriter:Dispose (Boolean disposing) in <0x00034> System.IO.StreamWriter:Close () in <0x0005c> LockBug:Main (System.String[] args) Expected Results: Should write the file normally. How often does this happen? Every time. Additional Information: I've tested shares exported both from Samba on Linux and from Windows XP with the same results. What is probably the same bug prevents mcs from compiling on a SMB share; the output .exe file is created with 0 byte size and the it aborts: $ mcs LockBug.cs ** ERROR **: WriteFile returned 33 aborting... Abort trap Comparing ktrace/kdump output from opening on a local filesystem and on a SMB share, I notice that it's trying to open /proc when writing to the SMB share. Mac OS X does not have a /proc filesystem, so this fails. Mono 1.1.7 and 1.0.5 both seem to fail the same way. I've only tested this under Mac OS X 10.4.1 (Tiger), not on older releases. ---- Additional Comments From brion@pobox.com 2005-05-21 02:15:49 MST ---- Created an attachment (id=167993) Simple test program; run it in a directory on a SMB share. ---- Additional Comments From brion@pobox.com 2005-05-21 02:39:30 MST ---- Created an attachment (id=167994) Diff of ktrace/kdump output running on local fs and SMB share ---- Additional Comments From brion@pobox.com 2005-05-21 02:41:24 MST ---- The /proc thing only seems to happen when overwriting an existing file on the SMB share, and doesn't seem to affect the outcome. The same error happens when creating a new file without a previous one, where no /proc check occurs. ---- Additional Comments From miguel@ximian.com 2005-05-21 08:33:03 MST ---- In addition to this bug, I would like to get rid of the lock_file_region block in file_write ---- Additional Comments From dick@ximian.com 2005-05-24 09:12:28 MST ---- Try this patch Miguel, I'll look at the locking change we discussed when I get back. ---- Additional Comments From dick@ximian.com 2005-05-24 09:13:13 MST ---- Created an attachment (id=167995) Locking patch ---- Additional Comments From bmaurer@users.sf.net 2005-05-29 19:27:59 MST ---- Miguel checked in this patch. Imported an attachment (id=167993) Imported an attachment (id=167994) Imported an attachment (id=167995) Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Mac OS X 10.4.1</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".