collapsing forks

Charles Hannum mycroft at kropotki.gnu.ai.mit.edu
Thu May 30 09:48:28 AEST 1991


In article <1991May24.215945.13707 at ddtg.com> pechner at ddtg.com (Michael Pechner) writes:

   I am having a very strange problem with A/UX.  I can cause a fork to 
   "sort of" fail by having a huge automatic variable.  Here are two 
   programs to show my point.  The only difference between the two programs 
   are that junk is an automatic in the version that fails, and a global static 
   The working program:

	   static char junk[256000];

   The non-working program.  The only difference is that "junk" is 
   an automatic variable.

	   main(){
		   /*...*/
		   char junk[256000];
	   }

   Notice that on the failed call, the fork returns a valid pid to the parent.
   The child does not return.
   The child process collapses immediately.

   Can anybody explain this to me?


I believe so.  B-)

In the first example, 'junk' is indeed being allocated at the top level, as a
global variable.  This means the space is allocated in a separate data
segment when the program is started.  Since presumably your machine has enough
RAM and/or virtual memory, this works.

In the second example, 'junk' is indeed being allocated as an automatic
variable.  Most C compilers cause this data to be placed on the stack.  For
some reason, tossing 250K on the stack at once gives A/UX indigestion, and
your program dies.  (As an aside:  On what systems, using what operating
systems, *will* this work, and on which ones will it crash the kernel?  B-) )



More information about the Comp.unix.wizards mailing list