lkml.org 
[lkml]   [1999]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: (fwd) Re: Why Linux CRASHES when process overscome swap memory ?????
On Wed, 27 Oct 1999, Rik van Riel wrote:

> On Wed, 27 Oct 1999, M Sweger wrote:
> > Francois THIEBOLT wrote:
> > > Got students writting progs (beginners & pros...), one of them made a
> > > test :
> > >
> > > #include <stdio.h>
> > > #include <stdlib.h>
> > >
> > > int main()
> > > {
> > > char *mem;
> > > const size_t TAILLE=1048576;
> > >
> > > while (1)
> > > {
> > > mem=(char *)malloc(TAILLE);
> > > }
> > > }
> > >
> > > Then linux start to allocate memory, then it uses memory swap and then
> > > it crashes (even mouse isn't responding)...then Reset.
> > >

This should do nothing bad at all! There is no read/write from any of this
memory so no pages are actually allocated. I seriously doubt that you
can crash any system with this code.


Script started on Wed Oct 27 10:56:41 1999
# cat zzz.c
#include <stdio.h>
#include <stdlib.h>

int main()
{
char *mem;
const size_t TAILLE=1048576;
while(1)
{
mem=(char*) malloc(TAILLE);
}
}

# gcc -o zzz zzz.c
# strace zzz
brk(0) = 0x80495d8
[SNIPPED......]


brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000
brk(0x400c6000) = 0x3ffc5000

^C
#
# exit
Script done on Wed Oct 27 10:57:10 1999

All it will do is settle down into a loop of setting the maximum
break-address over and over again.


Cheers,
Dick Johnson

Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.068 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site