mmapped memory lost after fork

Corinna Vinschen
Thu Jul 15 10:59:00 GMT 2004

On Jul 14 12:47, Tenedor Roquefort wrote:
> I'm using Cygwin 1.5.10-3 and have found what seems to
> be a fork/mmap bug. I have two examples where a forked
> child cannot access memory that was mmapped by the
> parent. The problem seems to arise when the parent
> munmaps some pages (different from the ones the child
> will try to access) before forking.
> In the example below, the parent mmaps 2 pages,
> munmaps the first page, writes to the second page and
> forks. Then both parent and child try to access the
> second page, the parent succeeds but the child dies
> trying. The examples work on Linux without the child
> dying. Has this problem been documented before and is
> there a known fix?
> Thanks.

Thanks for the test case!  It was very helpful.  It turned out to be
an off-by-one error in the child routine which generates the same
memory protection layout as in the parent process.

I've applied a fix and created a new developer snapshot.  Please give
it a try, see


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Co-Project Leader
Red Hat, Inc.

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list