Subject: Re: Bug in mmap() for files with holes
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Thor Lancelot Simon <tls@rek.tjls.com>
List: tech-kern
Date: 11/14/2007 17:09:37
On Wed, Nov 14, 2007 at 05:01:28PM -0500, der Mouse wrote:
> > We appear to have such a bug for _reading_ files consisting only of
> > holes; see the program below.  Modifying the program to write one
> > byte to the file before the lseek() that extends it causes the
> > segfault to go away.
> 
> 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!

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.

Thor