From owner-freebsd-questions Thu Mar 9 19: 7:59 2000 Delivered-To: freebsd-questions@freebsd.org Received: from thor.afnetinc.com (thor.afnetinc.com [206.40.232.1]) by hub.freebsd.org (Postfix) with ESMTP id C5F9337B919 for ; Thu, 9 Mar 2000 19:07:53 -0800 (PST) (envelope-from lists@efinley.com) Received: from 206-40-232-174-pm3-1.afnetinc.com ([206.40.232.174] helo=SCIENCE1) by thor.afnetinc.com with smtp (Exim 2.05 #1) id 12TFmG-0002cO-00; Thu, 9 Mar 2000 20:07:49 -0700 From: lists@efinley.com (Elliot Finley) To: Bhishan Hemrajani Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Code that crashes 3.4-Stable Date: Fri, 10 Mar 2000 03:09:55 GMT Organization: Hiawatha Coal Company Reply-To: lists@efinley.com Message-ID: <38c96656.29361402@mail.afnetinc.com> References: <200003100251.SAA05266@cytosine.dhs.org> In-Reply-To: <200003100251.SAA05266@cytosine.dhs.org> X-Mailer: Forte Agent 1.5/32.451 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG True, I could impose those limits, but the point is that the system crashes when it starts to swap... Should this be the case? How SHOULD FreeBSD handle this? In reality, I wouldn't WANT the system to swap, and if I was running low on RAM, I would add more... But if I didn't catch it in time, I would rather have the system take a BIG performance hit rather than crash... On Thu, 9 Mar 2000 18:51:38 -0800 (PST), Bhishan Hemrajani wrote: >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. >>=20 >> 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. >>=20 >> 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. >>=20 >> 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. >>=20 >> Here is the code, it was compiled with 'g++ -o test test.c' >> ----------------------------------------------------------- >>=20 >> #include >> #include >> #include >> #include >> #include >> //#include >>=20 >> void sig_child(int i) >> { >> int pid; >> int status; >>=20 >> while ( (pid =3D wait3(&status, WNOHANG, (struct rusage *) 0)) > 0) = ; >> } >>=20 >> main() >> { >> cout << "Hello World!" << endl; >>=20 >> void sig_child(int i); >>=20 >> signal(SIGCHLD, sig_child); >>=20 >> int iIsParent; >>=20 >> for(int i =3D 0; i < 8000; i++) { >> iIsParent =3D fork(); >> if(iIsParent < 0) { cout << "Error Forking!" << endl; } >> if(!iIsParent) { >> cout << "I'm child #" << i << endl; >> sleep(30); >> return 0; >> } >> } >>=20 >> sleep(10); >> cout << "Parent done." << endl; >> return 0; >> } >>=20 >> --=20 >> Elliot (efinley@efinley.com) Weird Science! >>=20 >>=20 >> To Unsubscribe: send mail to majordomo@FreeBSD.org >> with "unsubscribe freebsd-questions" in the body of the message >>=20 > --=20 Elliot (efinley@efinley.com) Weird Science! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message