From: Olivier Galibert <galibert@pobox.com>
To: linux-os <linux-os@analogic.com>
Cc: Rik van Riel <riel@redhat.com>, Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org,
James Antill <james.antill@redhat.com>,
Bryn Reeves <breeves@redhat.com>
Subject: Re: don't let mmap allocate down to zero
Date: Wed, 26 Jan 2005 19:10:06 +0100 [thread overview]
Message-ID: <20050126181006.GA80759@dspnet.fr.eu.org> (raw)
In-Reply-To: <Pine.LNX.4.61.0501261130130.17993@chaos.analogic.com>
On Wed, Jan 26, 2005 at 11:38:15AM -0500, linux-os wrote:
> On Wed, 26 Jan 2005, Rik van Riel wrote:
>
> >With some programs the 2.6 kernel can end up allocating memory
> >at address zero, for a non-MAP_FIXED mmap call! This causes
> >problems with some programs and is generally rude to do. This
> >simple patch fixes the problem in my tests.
>
> Does this mean that we can't mmap the screen regen buffer at
> 0x000b8000 anymore?
No. Missed the "non-MAP_FIXED" part? You can always map at 0, you
just have to ask for it.
> What 'C' standard do you refer to?
Malloc uses mmap to get more memory. Malloc returning 0 means no
memory, not "the memory happens to be at 0". Not that easy to fix in
the glibc if you want to keep the "segfault on null pointer accesses"
debugging help too.
Given that the man page itself says that unless you're using MAP_FIXED
start is only a hint and you should use 0 if you don't care things can
get real annoying real fast. Imagine if you want to mmap a <4K file
and mmap then returns 0, i.e. NULL, as the mapping address as you
asked. It's illegal from the point of view of susv3[1] and it's real
annoying in a C/C++ program.
OG.
[1]
When MAP_FIXED is not set, the implementation uses addr in an
implementation-defined manner to arrive at pa. The pa so chosen
shall be an area of the address space that the implementation deems
suitable for a mapping of len bytes to the file. All implementations
interpret an addr value of 0 as granting the implementation complete
freedom in selecting pa, subject to constraints described below. A
non-zero value of addr is taken to be a suggestion of a process
address near which the mapping should be placed. When the
implementation selects a value for pa, it never places a mapping at
address 0, nor does it replace any extant mapping.
next prev parent reply other threads:[~2005-01-26 23:31 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-26 16:18 Rik van Riel
2005-01-26 16:38 ` linux-os
2005-01-26 17:05 ` Sytse Wielinga
2005-01-26 17:34 ` Chris Friesen
2005-01-26 17:57 ` Bryn Reeves
2005-01-26 18:37 ` linux-os
2005-01-26 18:54 ` Rik van Riel
2005-01-26 19:09 ` linux-os
2005-01-26 19:13 ` Chris Friesen
2005-01-26 19:08 ` Chris Friesen
2005-01-26 18:10 ` Olivier Galibert [this message]
2005-01-26 18:20 ` linux-os
2005-01-26 18:31 ` Olivier Galibert
2005-01-26 18:39 ` linux-os
2005-01-26 19:41 ` Arjan van de Ven
2005-01-26 20:26 ` Andy Isaacson
2005-01-26 20:42 ` Rik van Riel
2005-01-26 22:12 ` Kyle Moffett
2005-01-26 23:31 ` Brian Gerst
2005-01-26 17:25 ` William Lee Irwin III
2005-01-27 5:09 ` William Lee Irwin III
2005-01-27 5:18 ` Dave Jones
2005-01-27 5:28 ` William Lee Irwin III
2005-01-27 9:29 ` Mikael Pettersson
2005-01-27 12:52 ` William Lee Irwin III
2005-01-27 14:25 ` Russell King
2005-01-27 15:12 ` William Lee Irwin III
2005-01-27 19:22 ` Rik van Riel
2005-01-27 20:44 ` William Lee Irwin III
2005-01-27 20:58 ` Rik van Riel
2005-01-27 21:13 ` William Lee Irwin III
2005-01-27 21:28 ` Rik van Riel
2005-01-28 5:30 ` William Lee Irwin III
2005-01-28 13:01 ` Rik van Riel
2005-01-28 14:14 ` Hugh Dickins
2005-01-28 14:26 ` William Lee Irwin III
2005-01-28 15:41 ` Rik van Riel
2005-01-28 15:53 ` Hugh Dickins
2005-01-27 21:58 ` linux-os
2005-01-27 14:26 ` Mikael Pettersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050126181006.GA80759@dspnet.fr.eu.org \
--to=galibert@pobox.com \
--cc=akpm@osdl.org \
--cc=breeves@redhat.com \
--cc=james.antill@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.com \
--cc=riel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome