[darcs-users] strange bug with Windows share mounted on Mac OS X

David Roundy droundy at abridgegame.org
Fri Oct 22 11:55:44 UTC 2004


On Wed, Oct 20, 2004 at 02:49:10PM +0200, Peter Strand wrote:
> David Roundy wrote:
> 
> >I don't actually check on whether mmap is safe.  I just open a temporary
> >file and try to delete it before closing it.  If it fails, we're on a
> >system where mmap could be dangerous, since we never explicitly munmap
> >(leave that to the GC), so we don't mmap.  And I only run the check before
> >doing an mmap_slurp, which itself is a slow operation, so I don't think the
> >cost will be noticable.
> 
> Wouldn't it be enough to do this test just once, perhaps in the _darcs 
> directory, and avoid mmap if it fails?
>
> Then we could get rid of the --disable-mmap flag to configure and always 
> rely on run-time testing.

That would definitely a nice goal, but we'd need to do the test at least
twice... once in the _darcs directory and once in the TMPDIR directory.
Which makes me wonder if just doing the check every time we want to mmap
would be simplest.

I think there are currently only two uses of mmap that aren't tested by the
slurp test that I added.  One is in Send and one in Match.  But at least
for now, getting rid of the --disable-mmap flag seems unwise, since it will
be necesary to test if our tests are failing.

> However, is it ever useful to mmap files without relying on finalizers 
> to unmap them? i.e. explicitly unmap?
> In that case we could start to use mmap in windows as well, where it is 
> safe wrt. unmapping.

I don't think so.  In theory it's possible to be useful, but since the only
benefit of running mmap is in not having to copy the data into separate
memory, this could only be used in an IO operation that doesn't have any
output that contains the content of the file that was mmapped.  E.g. it
would be useful for hashing or word-counting... oh, there I just answered
myself.  For binary files, we could use mmap and an explicit munmap (since
we could convert them to hex before munmapping).

There also are instances where the mmapped file doesn't change.  For
example in Match, the mmapped file is a user input, and we don't modify or
delete it, so that mmap should be safe on windows.  Actually, now that I
look at it, the mmap in Send is also safe.  So someone could try already
compiling on windows without --disable-mmap, and see what happens...
-- 
David Roundy
http://www.abridgegame.org




More information about the darcs-users mailing list