From owner-freebsd-questions Thu Mar 9 18:51:51 2000 Delivered-To: freebsd-questions@freebsd.org Received: from cytosine.dhs.org (cx272244-a.orng1.occa.home.com [24.1.177.149]) by hub.freebsd.org (Postfix) with ESMTP id A389837B8FE for ; Thu, 9 Mar 2000 18:51:46 -0800 (PST) (envelope-from bhishan@cytosine.dhs.org) Received: (from bhishan@localhost) by cytosine.dhs.org (8.9.3/8.9.3) id SAA05266; Thu, 9 Mar 2000 18:51:38 -0800 (PST) (envelope-from bhishan) From: Bhishan Hemrajani Message-Id: <200003100251.SAA05266@cytosine.dhs.org> Subject: Re: Code that crashes 3.4-Stable In-Reply-To: <38c85e65.27328632@mail.afnetinc.com> from Elliot Finley at "Mar 10, 2000 02:47:19 am" To: lists@efinley.com Date: Thu, 9 Mar 2000 18:51:38 -0800 (PST) Cc: freebsd-questions@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG It does work when there are no limits on the users. I recommend that everyone audits their users using /etc/login.conf. I have my users limited to 32 processes, and 16m per process. It didn't crash my system when I was logged in as a limited user. --bhishan P.S, after editing /etc/login.conf you have to 'cap_mkdb /etc/login.conf' > I'm in the process of stress testing a system for a program that I'm > writing. This program will be starting lots of processes, so I wrote > a short bit a code to test this out. > > The machine is 3.4-stable as of a couple of days ago, PII-350 384M > RAM, and 500M swap. The kernel has MAXUSERS 512, which should give us > about 8200 process slots. After forking approx. 5100 children > processes, the machine runs out of RAM, and starts using swap, after > about 64K of swap is used (as shown by top), the machine freezes > solid. No core, no logged messages, no socket activity, no messages > on console, nothing. > > If someone can see a problem with the code, I would appreciate some > pointers. But even if there IS a problem... You shouldn't be able to > crash the system with a user program running with no privileges. > > If I take out the 'sleep(30)' from the child process, then this > program runs fine, even with the loop counter set to 100,000 (one > hundred thousand), because the child processes go away fast enough > that I can only get about 400 of them running at any one time. The > problem seems to be when the machine runs out of memory, and starts to > swap. > > Here is the code, it was compiled with 'g++ -o test test.c' > ----------------------------------------------------------- > > #include > #include > #include > #include > #include > //#include > > void sig_child(int i) > { > int pid; > int status; > > while ( (pid = wait3(&status, WNOHANG, (struct rusage *) 0)) > 0) ; > } > > main() > { > cout << "Hello World!" << endl; > > void sig_child(int i); > > signal(SIGCHLD, sig_child); > > int iIsParent; > > for(int i = 0; i < 8000; i++) { > iIsParent = fork(); > if(iIsParent < 0) { cout << "Error Forking!" << endl; } > if(!iIsParent) { > cout << "I'm child #" << i << endl; > sleep(30); > return 0; > } > } > > sleep(10); > cout << "Parent done." << endl; > return 0; > } > > -- > Elliot (efinley@efinley.com) Weird Science! > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message