This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: malloc using mprotect
- To: jakub at redhat dot com
- Subject: Re: malloc using mprotect
- From: Wolfram Gloger <Wolfram dot Gloger at dent dot med dot uni-muenchen dot de>
- Date: Fri, 10 Aug 2001 11:12:31 +0200 (MDT)
- CC: libc-alpha at sources dot redhat dot com, Wolfram dot Gloger at dent dot med dot uni-muenchen dot de
- References: <20010806070124.J3862@devserv.devel.redhat.com> <Pine.LNX.4.33.0108061015450.8972-100000@penguin.transmeta.com> <20010809120050.T3862@devserv.devel.redhat.com>
Hello,
> What's the exact reason for using mmap(..., PROT_NONE, ...) first and then
> mprotect (..., PROT_READ|PROT_WRITE) chunk by chunk instead of
It's actually happening in rather bis chunks, _not_ individually for
every malloc()ed chunk larger than a page.
> mmap(..., PROT_READ|PROT_WRITE, ...) first and nothing afterwards?
> Is it primarily to catch bogus programs?
No, not primarily.
> Or is it primarily so that the whole heap does not count immediately into
> rlimits, but slowly as malloc areas are requested?
Yes, that is one of the main reasons. After all, the heaps are quite
huge (or at least were quite huge in 1996 :).
> If we explain it to Linus, I guess he could accept mprotect(2) patches to do
> some merging in the common case.
What exactly is the problem?
Regards,
Wolfram.