Subject: How to kill NetBSD-Sparc without really trying
To: None <MLARKIN@CSUPomona.Edu>
From: David Gilbert <dgilbert@jaywon.pci.on.ca>
List: port-sparc
Date: 02/15/1996 20:14:47
>>>>> "MLARKIN" == MLARKIN  <MLARKIN@CSUPomona.Edu> writes:

MLARKIN> I succeeded in killing my IPC last night running 1.1A. I
MLARKIN> wasn't really trying to load down the system, but an errant
MLARKIN> process got out of line and went on a malloc() swarm (or so
MLARKIN> it appeared).

MLARKIN> What happens to the system if a process tries to allocate
MLARKIN> little pieces of memory hundreds, thousands, millions of
MLARKIN> times?

	Bascially, in UN*X, malloc() calls something called brk().
brk()'s job is to move the end of the data segment down in memory in
chunks.  Your many small allocations will be translated in to your
process growing in chunks.  The size of these chunks is something that
malloc() determines, but that are at least as big as your malloc()
request.

[description of process deleted]

MLARKIN> About 30 seconds into the run, the system froze completely,
MLARKIN> after consistently getting slower and slower. All attempts to
MLARKIN> stop the runaway process failed.

MLARKIN> I had a systat:vmstat running in another window, and watched
MLARKIN> the pi program eat 7mb before the vmstat was shut out
MLARKIN> completely.

MLARKIN> Thinking I could "ride it out" , I left the process running
MLARKIN> for a few hours, the disk thrashing to all hell. Finally,
MLARKIN> everything stopped. No brain activity.  Clinical system
MLARKIN> death.

MLARKIN> Any clues as to how a simple (?) usermode program could eat
MLARKIN> up all the ram and not cause a seg viol. ? Or kernel
MLARKIN> termination at the very least. Some sort of graceful exit.

	Your system can set hard and soft limits on the amount of
memory a single process may use.  It is quite bad if a single process
can use all available memory.  The system deals with this poorly.

	When you are testing software of this nature on a machine with
a small amount of total memory (RAM + swap), you may want to set your
'limit' or 'ulimit' (depends on the shell you're using) on the amount
of memory you allow the process to use.  This will then kill the
process before it get to the condition of 'clinical death.'

Dave.

-- 
----------------------------------------------------------------------------
|David Gilbert, PCI, Richmond Hill, Ontario.  | Two things can only be     |
|Mail:      dgilbert@jaywon.pci.on.ca         |  equal if and only if they |
|http://www.pci.on.ca/~dgilbert               |   are precisely opposite.  |
---------------------------------------------------------GLO----------------