Re: A test malloc program makes 64-Bit FC-4 dying

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 04 November 2005 00:16, Jonathan Berry wrote:
> On 11/3/05, Reuben D. Budiardja <techlist@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> > Hello,
> > I have a small program that I use to check malloc. The program supposed
> > to exhaust memory (heap) from malloc, then quit.<snip>
> > However, when I run this program on my desktop: AMD64 FC 4 64-bit, the
> > program does not terminate after a while. But it grinds this machine to
> > almost to a halt, and I got page-swapping, etc. 
<snip>
> > ------ kgobble.c----
> > #include <stdio.h>
> > #include <string.h>
> >
> > main()
> > {
> >   int *i;
> >   int j=1;
> >   char buf[15];
> >
> >   printf("Starting kgobble\n");
> >
> >   while(1)
> >   {
> >     i=(int *)malloc(8176 * j);
> >     if (i==0)
> >     {
> >       write(1,"Memory exhaustion complete\n",27);
> >       exit(0);
> >     }
> >     sprintf(buf,"%x\n",i);
> >     write(1,buf,strlen(buf));
> >     bzero(buf,15);
> >     j++;
> >   }
> > }
> >
> >
> > RDB
>
> Hi Reuben,
>
> Question: At what value of i does the above program die when on a
> 32-bit machine?  

Did you mean the value of "j" ? "i" in this case is the memory address (which 
of course varies between machines and runs). But in any case, for an example, 
in my 32-bit machine, right before it terminate:
i = 0xbf403008, j = 884

After that, i would be NULL, then it terminates. I found that the value of j 
is about the same on different 32-bit machines.

<snip>
> My initial response to your email was that you are seeing a virtual
> memory difference here, whether or not my speculation is completely
> accurate, I think this at least has something to do with it.

hm.. interesting thought. I guess I'll try to poke around to see the virtual 
memory differences. This probably gives me a pointer in the right direction. 
Thanks.

> What 
> exactly are you trying to accomplish with this program?  I guess you
> are trying to make sure that someone cannot pull a "fork bomb" like
> resource DoS attack?

Well, actually for my learning purpose and academic reason I started to write 
my own malloc version. This program is a rather crude way to check an 
implementation of malloc. But then I stumbled on this problem when playing 
with different machines, and it got me really curious. 

Reuben D. Budiardja


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux