Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Jun 1996 02:58:28 -0700
From:      Josh MacDonald <jmacd@CS.Berkeley.EDU>
To:        freebsd-hackers@freebsd.org
Subject:   strange mmap programming bug
Message-ID:  <199606120958.CAA19589@paris.CS.Berkeley.EDU>

next in thread | raw e-mail | index | archive | help

I'm having this problem.  I don't know if its only on FreeBSD or not,
as I have only experienced it on FreeBSD and its hard to reproduce.

Occasionally, when a program of mine exits abnormally, it seems that
small files which were opened O_RDONLY and then mmaped are being
modified.  I am mmaping the entire file.  I have only noticed this
for files smaller than PAGESIZE.  The file's length is changed to
be exactly 4096 bytes with zero's padding the original data.

Basically, its

	fd = open(filename, O_RDONLY)
	fstat(fd, &sbuf)
	mmap(0, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0)

with the appropriate error checks.

Does anyone have an idea what could be happening?

-josh



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606120958.CAA19589>