[erlang-bugs] Bug in file I/O under Windows.

John Hughes john.hughes@REDACTED
Tue Mar 4 15:10:52 CET 2008


This bug manifests as follows:

 

Suppose FileName is the name of an existing file to which we have access.

 

                             file:delete(FileName)
returns ok

                             file:write_file(FileName,Bin)
returns {error,eacces}

 

This ought not to happen, because we do have access to the file. The
documentation says eacces means "Missing permission for writing the file or
searching one of the parent directories", but neither of these is the
case-and indeed, if we repeat the same test, then it will almost always
succeed as it should.

 

Unfortunately, this bug is rare and very hard to reproduce, so I can't
include instructions for doing so. I found the problem by running random
sequences of file:write_file and file:delete commands, operating on a small
set of filenames. I tried to get repeatable tests by running each test in a
newly created directory, on a newly spawned Erlang node, and after a
timer:sleep-but even so, I found that a sequence which failed once could
very well go on to succeed the next 100 times I tried it.  However, I have
been able to collect about 40 examples of the bug using QuickCheck. All of
them take the form above; they range in length from 4 commands to over
2,000. There are sometimes operations on other files between the delete and
the write_file that fails, but never further operations on FileName itself.

 

I've observed this behaviour under R11B and R12B, under both Windows XP and
Vista. It doesn't appear to happen at all under Linux.

 

John Hughes

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20080304/6bf16769/attachment.htm>


More information about the erlang-bugs mailing list