Austin Group Bug Tracker
2014-06-24 22:11:27 UTC
The following issue has been SUBMITTED.
======================================================================
http://austingroupbugs.net/view.php?id=850
======================================================================
Reported By: mdempsky
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 850
Category: System Interfaces
Type: Enhancement Request
Severity: Editorial
Priority: normal
Status: New
Name: Matthew Dempsky
Organization: OpenBSD
User Reference:
Section: mmap
Page Number:
Line Number:
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-06-24 22:11 UTC
Last Modified: 2014-06-24 22:11 UTC
======================================================================
Summary: Standardize MAP_ANON
Description:
It seems that all modern UNIX-like systems provide an mmap() flag to allow
allocating anonymous memory directly without needing a file descriptor.
Here are my notes from looking through various online manual pages (e.g.,
Solaris, Linux, *BSD, AIX, HPUX, UnixWare):
1. Most systems call it MAP_ANON, but HPUX, AIX, and UnixWare call it
MAP_ANONYMOUS. Some systems provide both; e.g., FreeBSD.
2. Mac OS X allows Mach VM flags to be passed via the "fd" parameter,
but recognizes "-1" as "no flags". Other OSes reject MAP_ANON(YMOUS)?
with fd != -1. Common practice seems to be EINVAL, but at least AIX
specifies EBADF instead.
3. FreeBSD requires offset==0 when using MAP_ANON; Linux and Mac OS X
explicitly document that it's ignored, and other OSes don't seem to
care.
First attempt at desired action below. I made a best effort at formatting
it as I've seen done in previous bug reports. Two notes:
1. Defining a new "anonymous memory object" type seemed the easiest way
to tackle the idea, but the definition is kind of weak. Maybe there's a
better way to define it.
2. There are a *lot* of places in mmap() that mention "fildes", and it
would be tedious to add "Unless MAP_ANON is specified" to all of them, so I
tried to word MAP_ANON to make it clear that fildes shouldn't matter. Not
sure if that's appropriate.
Desired Action:
In XBD 3 Definitions, add (and renumber subsequent entries as
appropriate):
3.XXX Anonymous Memory Object
An object that represents memory not associated with any other
memory objects.
In XBD 3 Definitions under 3.220 Memory Object, between "A file" and "A
shared memory object", add:
* An anonymous memory object (see <a>Anonymous Memory Object</a>).
In <sys/mman.h> under the "symbolic constants for use as flag options"
section, add:
MAP_ANON
Map anonymous memory.
In mmap() under "The mmap() function shall be supported for the following
memory objects", add:
* Anonymous memory objects.
In mmap()'s table about MAP_* symbolic constants, add a row:
MAP_ANON | Map anonymous memory.
In mmap() at an appropriate place (e.g., after the paragraph beginning with
"If MAP_FIXED is specified and <i>addr</i> is non-zero"?), add a
paragraph:
If MAP_ANON is specified, <i>fildes</i> is -1, and <i>off</i> is 0,
then <i>mmap</i>() shall ignore <i>fildes</i> and instead establish a
mapping to a new anonymous memory object of size <i>length</i>. The effect
of specifying MAP_ANON with other values of <i>fildes</i> or <i>off</i> is
unspecified.
In msync() change:
[SHM|TYM]The effect of <i>msync</i>() on a shared memory object or a
typed memory object is unspecified.[/]
to:
The effect of <i>msync</i>() on an anonymous memory object, [SHM]shared
memory object[/], or [TYM]typed memory object[/] is unspecified.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-06-24 22:11 mdempsky New Issue
2014-06-24 22:11 mdempsky Name => Matthew Dempsky
2014-06-24 22:11 mdempsky Organization => OpenBSD
2014-06-24 22:11 mdempsky Section => mmap
======================================================================
======================================================================
http://austingroupbugs.net/view.php?id=850
======================================================================
Reported By: mdempsky
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 850
Category: System Interfaces
Type: Enhancement Request
Severity: Editorial
Priority: normal
Status: New
Name: Matthew Dempsky
Organization: OpenBSD
User Reference:
Section: mmap
Page Number:
Line Number:
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-06-24 22:11 UTC
Last Modified: 2014-06-24 22:11 UTC
======================================================================
Summary: Standardize MAP_ANON
Description:
It seems that all modern UNIX-like systems provide an mmap() flag to allow
allocating anonymous memory directly without needing a file descriptor.
Here are my notes from looking through various online manual pages (e.g.,
Solaris, Linux, *BSD, AIX, HPUX, UnixWare):
1. Most systems call it MAP_ANON, but HPUX, AIX, and UnixWare call it
MAP_ANONYMOUS. Some systems provide both; e.g., FreeBSD.
2. Mac OS X allows Mach VM flags to be passed via the "fd" parameter,
but recognizes "-1" as "no flags". Other OSes reject MAP_ANON(YMOUS)?
with fd != -1. Common practice seems to be EINVAL, but at least AIX
specifies EBADF instead.
3. FreeBSD requires offset==0 when using MAP_ANON; Linux and Mac OS X
explicitly document that it's ignored, and other OSes don't seem to
care.
First attempt at desired action below. I made a best effort at formatting
it as I've seen done in previous bug reports. Two notes:
1. Defining a new "anonymous memory object" type seemed the easiest way
to tackle the idea, but the definition is kind of weak. Maybe there's a
better way to define it.
2. There are a *lot* of places in mmap() that mention "fildes", and it
would be tedious to add "Unless MAP_ANON is specified" to all of them, so I
tried to word MAP_ANON to make it clear that fildes shouldn't matter. Not
sure if that's appropriate.
Desired Action:
In XBD 3 Definitions, add (and renumber subsequent entries as
appropriate):
3.XXX Anonymous Memory Object
An object that represents memory not associated with any other
memory objects.
In XBD 3 Definitions under 3.220 Memory Object, between "A file" and "A
shared memory object", add:
* An anonymous memory object (see <a>Anonymous Memory Object</a>).
In <sys/mman.h> under the "symbolic constants for use as flag options"
section, add:
MAP_ANON
Map anonymous memory.
In mmap() under "The mmap() function shall be supported for the following
memory objects", add:
* Anonymous memory objects.
In mmap()'s table about MAP_* symbolic constants, add a row:
MAP_ANON | Map anonymous memory.
In mmap() at an appropriate place (e.g., after the paragraph beginning with
"If MAP_FIXED is specified and <i>addr</i> is non-zero"?), add a
paragraph:
If MAP_ANON is specified, <i>fildes</i> is -1, and <i>off</i> is 0,
then <i>mmap</i>() shall ignore <i>fildes</i> and instead establish a
mapping to a new anonymous memory object of size <i>length</i>. The effect
of specifying MAP_ANON with other values of <i>fildes</i> or <i>off</i> is
unspecified.
In msync() change:
[SHM|TYM]The effect of <i>msync</i>() on a shared memory object or a
typed memory object is unspecified.[/]
to:
The effect of <i>msync</i>() on an anonymous memory object, [SHM]shared
memory object[/], or [TYM]typed memory object[/] is unspecified.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-06-24 22:11 mdempsky New Issue
2014-06-24 22:11 mdempsky Name => Matthew Dempsky
2014-06-24 22:11 mdempsky Organization => OpenBSD
2014-06-24 22:11 mdempsky Section => mmap
======================================================================