[darcs-devel] [issue1753] darcs: opening of '_darcs/index' failed: does not exist (No such file or directory)

Ferenc Wágner bugs at darcs.net
Thu Mar 4 17:08:44 UTC 2010


Ferenc Wágner <wferi at niif.hu> added the comment:

"Trent W. Buck" <bugs at darcs.net> writes:

> What happens if you build Darcs 2.4 against an mmap-0.5-based
> hashed-storage, but pass -f-mmap to Darcs?

Hell breaks loose:

stat64("_darcs/index_invalid", 0xb6f47330) = -1 ENOENT (No such file or directory)
stat64("_darcs/index", {st_mode=S_IFREG|0664, st_size=200, ...}) = 0
open("_darcs/index", O_RDONLY|O_NOCTTY|O_LARGEFILE) = 6
fstat64(6, {st_mode=S_IFREG|0664, st_size=200, ...}) = 0
mmap2(NULL, 4, PROT_READ, MAP_PRIVATE, 6, 0) = 0xb7791000
close(6)                    = 0
stat64("_darcs/index", {st_mode=S_IFREG|0664, st_size=200, ...}) = 0
stat64("_darcs/index", {st_mode=S_IFREG|0664, st_size=200, ...}) = 0
open("_darcs/index", O_RDWR|O_NOCTTY|O_LARGEFILE) = 6
fstat64(6, {st_mode=S_IFREG|0664, st_size=200, ...}) = 0
close(6)                    = 0
write(2, "darcs: "..., 7)   = 7
write(2, "mmap of '_darcs/index' failed, of"..., 109) = 109
write(2, "\n"..., 1)        = 1
darcs: mmap of '_darcs/index' failed, offset and size beyond end of file: does not exist (No such file or directory)

As far as I can see, we're in Darcs/Repository/State.hs:readIndex
starting with two doesFileExist (stat64) calls, then I.indexFormatValid
(open, fstat64, mmap2, close) returns True, thus finally I.readIndex
calling mmapIndex, doing another doesFileExist (stat64) and a
getFileStatus (stat64), then mmapFileForeignPtr calls mmapFilePtr, which
calls mmapFileOpen (open) then sanitizeFileRegion, which calls
c_system_io_file_size (fstat64) but doesn't like the size and offset
values.  The throwErrno function isn't appropriate here, as the error
has nothing to do with errno and the corresponding error string.

readIndex says: mmapIndex indexpath 0, so size becomes act_size there,
and mmapFileForeignPtr gets called with range (0,act_size+size_magic),
ie. a range size_magic (4) bytes longer than the file itself.  Thus
longsize<(offset + fromIntegral size) is true, and sanitizeFileRegion
throws the error.

I'd say we found a bug in hashed-storage's mmapIndex, probably exhibited
by the new mmap interface.  And another in mmap (throwErrno usage).
-- 
Regards,
Feri.

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/issue1753>
__________________________________


More information about the darcs-devel mailing list