mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Vincent Lefevre <vincent@vinc17.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [2.4.26] overcommit_memory documentation clarification
Date: Sat, 8 May 2004 22:04:30 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.53.0405082142100.25076@chaos> (raw)
In-Reply-To: <20040509001045.GA23263@ay.vinc17.org>

On Sun, 9 May 2004, Vincent Lefevre wrote:

> Hi,
>
> The documentation of overcommit_memory in Documentation/sysctl/vm.txt
> should be clarified, as with the following simple program, malloc()
> never returns 0 on an official 2.4.26 kernel, even if overcommit_memory
> has been set to 0. Running it has the effect of having random processes
> killed, and eventually this process itself.

What made you think that malloc would return 0 if the system
was "out of memory??" Malloc will return NULL, which is not 0 BTW,
if you are out of address-space or have corrupted it by writing
past a previous allocation. Malloc's return value is a void *. It
should be compared against NULL, not zero.

When malloc() needs new "memory". It just asks the kernel to
set the new break address or, in the case of mmap() mallocs, asks
to extend a mapped region. Until somebody actually uses those
regions, you haven't used any memory. So there is no way for
malloc() to "know" ahead of time.

If you run a malloc() bomb from the root account you should
end up killing off a lot of processes. If you run it from
a normal user account, and you have set the user's resource
quotas properly, only the user should get into trouble.


Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5557.45 BogoMips).
            Note 96.31% of all statistics are fiction.



  reply	other threads:[~2004-05-09  2:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-09  0:10 Vincent Lefevre
2004-05-09  2:04 ` Richard B. Johnson [this message]
2004-05-09  2:20   ` Vincent Lefevre
2004-05-09 21:06     ` Paul Jackson
2004-05-09 21:49       ` Vincent Lefevre
2004-05-27 12:20         ` Marcelo Tosatti
2004-05-27 12:30           ` Marc-Christian Petersen
2004-05-27 13:09             ` Marcelo Tosatti
2004-05-27 13:19               ` Dave Jones
2004-05-27 21:12               ` Alan Cox

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=Pine.LNX.4.53.0405082142100.25076@chaos \
    --to=root@chaos.analogic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vincent@vinc17.org \
    /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

all inboxes | Powered by JetHome®