Subject: Re: Bug in mmap() for files with holes
To: None <email@example.com>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
Date: 11/14/2007 17:37:03
>>> We appear to have such a bug for _reading_ files consisting only of
>>> holes; see the program below.
>> On most filesystems, writing one byte allocates at least 1024 bytes
>> of storage and thus causes your test file to have no holes.
> Yes, that's exactly what I said! If the file doesn't have a hole,
> the segfault goes away!
Well, you wrote of "files consisting only of holes", which, to me,
carries an implication that the bug has something to do with files
containing no non-holes, which I doubt is the case; more likely, it's
simply a question of hitting a hole or not, whether or not there are
non-holes elsewhere in the file.
> The program as I sent it to the list, however, does not write the
> byte, and exhibits the bug. Clearly it should not segfault, since
> mmap returned a valid address, not MAP_FAILED.
Well, except the file is still zero bytes, so you're accessing memory
past EOF; a segfault is entirely reasonable.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML firstname.lastname@example.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B