Bug 210313 - Man page mmap(2) incorrectly states hint alignment requirement
Summary: Man page mmap(2) incorrectly states hint alignment requirement
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: man
Version: 5
Hardware: All
OS: Linux
medium
low
Target Milestone: ---
Assignee: Ivana Varekova
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-10-11 14:34 UTC by William Kucharski
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2006-10-20 11:25:17 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description William Kucharski 2006-10-11 14:34:21 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.8.0.7) Gecko/20060915 Firefox/1.5.0.7

Description of problem:
The man page for mmap(2) states the following concerning the address hint passed to mmap():

       The  address  start must be a multiple of the page size.

and:

       EINVAL We  don't  like  start or length or offset.  (E.g., they are too
              large, or not aligned on a PAGESIZE boundary.)

In fact, if "start" is unaligned, it is rounded up to the next PAGESIZE boundary by mmap(2).  No error is returned unless MAP_FIXED is specified.

Instead, the man page should state that if "start" is an unaligned address hint, it will be rounded up to the next PAGESIZE boundary.

Version-Release number of selected component (if applicable):
man-pages-2.21-1

How reproducible:
Always


Steps to Reproduce:
1. Save the following program as m.c:

#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

int
main()
{
        void *ptr;
        int fd;

        if ((fd = open("m.c", O_RDWR)) < 0) {
                perror("m.c");
                exit(1);
        }

        if ((ptr = mmap((void *)1, 0x500, PROT_READ, MAP_SHARED, fd,
            0)) == MAP_FAILED) {
                perror("mmap");
                (void) close(fd);
                exit (1);
        }

        printf("mmap #1 succeeded, ptr @ %p = 0x%x\n", ptr, *(int *)ptr);

        (void) close(fd);
        exit(0);
}

2. Compile m.c (gcc m.c)

3. Run the program and notice it does not fail with EINVAL.

Actual Results:
# ./a.out
mmap #1 succeeded, ptr @ 0x1000 = 0x636e6923


Expected Results:
According to the man page, this should have failed with the same results given if MAP_FIXED is specified:

mmap: Invalid argument


Additional info:

Comment 1 Ivana Varekova 2006-10-20 11:25:17 UTC
Fixed in man-pages-2.41-2.fc7.


Note You need to log in before you can comment on or make changes to this bug.