Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Nov 2003 20:52:44 +0100 (CET)
From:      Dimitry Andric <dim@tensor.xs4all.nl>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/59225: munmap semantics change break cp (and possibly other stuff)
Message-ID:  <20031112195244.E974F2285D@tensor.xs4all.nl>
Resent-Message-ID: <200311122000.hACK0djD000992@freefall.freebsd.org>

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

>Number:         59225
>Category:       bin
>Synopsis:       munmap semantics change break cp (and possibly other stuff)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 12 12:00:39 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Dimitry Andric
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
n/a
>Environment:
System: FreeBSD tensor.xs4all.nl 5.1-CURRENT FreeBSD 5.1-CURRENT #0: Tue Nov 11 12:27:59 CET 2003 root@vfbsd5.dim:/usr/obj/usr/src/sys/TENSOR i386
>Description:
In the log for src/sys/vm/vm_map.c, rev 1.321, it says:
  - The Open Group Base Specifications Issue 6 specifies that an munmap(2)
    must return EINVAL if size is zero.  Submitted by: tegge

This breaks cp(2) on zero-sized files, since it uses mmap/munmap for
small (<8MB) files by default.

Note that there may be other programs which use mmapping of zero-sized
files, these will probably break too, unless they ignore munmap's
return value.
>How-To-Repeat:
- Upgrade to -CURRENT after Mon Nov 10 01:37:40 2003 UTC.
- Try to cp a zero-byte regular file.
- Observe error: "cp: Invalid argument".
>Fix:
The simplest fix is to disable the memory mapping stuff in cp, by
commenting the line:

  CFLAGS+= -DVM_AND_BUFFER_CACHE_SYNCHRONIZED

in src/bin/cp/Makefile. However, it would be nicer to fix it properly.
How that should be done, when mmap'ing zero bytes succeeds, but
munmap'ing it doesn't, isn't entirely clear... Maybe it's better to
wait until the mmap API stabilizes. :)
>Release-Note:
>Audit-Trail:
>Unformatted:



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