Messages in this thread | | | Date | Wed, 15 Dec 1999 18:24:29 -0500 (EST) | From | "Mike A. Harris" <> | Subject | Re: linux crashed with unchecked malloc ?? |
| |
On Wed, 15 Dec 1999, vinny wrote:
> The problem that I came across was an offshoot of a joke in humorix , >where linus trovalds plays a role of a detective trying to see why a linux box >crashed and failed to boot again. This is the code I wrote to see how linux >handles the situation > >void guess_what () >{ > char *p = malloc (1024*1024); > guess_what (); >} > >void main () >{ > guess_what (); >} > >I compiled and ran the program once , it segfaulted , and then I ran it twice >again , all the time it segfaulted as expected. But then when I checked up my >hard disk space , I had 0 bytes free. To verify the same , I asked my friend to >run the same code again , except he modified the malloc statement to following: > > char *p = malloc (4096*1024); > >This time his entire system freezed up , then init reported it has run out of >memory , when we tried to login from another console , klogd said out of memory >and the system just froze , allowing us no chance to kill the culprit process.
You're telling the kernel that you want to allocate all memory in the machine, and it is letting you. In addition, the kernel allows software to allocate more virtual memory than the system contains. This is called "overcommit" because a lot of software allocates memory "just in case" it needs it, but never actually uses it. Thus, on any system with or without overcommit, anyone can easily grab all available memory. If this is not a desired effect, one can simply enable process accounting, and use the shell ulimit command to limit resources such as memory, disk quotas can limit disk usage.
You're saying that the system ran out of disk space? I can't see how running a program that does not write to the disk can use all the disk space. I can see how it could easily eat up all physical memory, and then your swap space, but not your available disk space. Please elaborate.
> We ran the code again after hard reset , and this time we got a bus >error and the program exited. When we checked up the hard disk space we found >again that disk space had been gobbled up leaving a very little amount free.
Elaborate on "checked up the hard disk space". What hard disk space, and how did you check it? What commands did you run, and what were the results? How did this differ from what you expected? A screenshot of the output of the commands you ran would be intuitive as well.
TTYL
-- Mike A. Harris Linux advocate Computer Consultant GNU advocate Capslock Consulting Open Source advocate
Join the FreeMWare project - the goal to produce a FREE program in which you can run Windows 95/98/NT, and other operating systems.
http://www.freemware.org
- 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/
| |