Subject: Re: kernel bug in NetBSD/Amiga? Help!
To: Jake Hamby <>
From: Calvin <>
List: amiga
Date: 12/17/1995 07:10:07
On Sat, 16 Dec 1995, Jake Hamby wrote:

> I've still been having trouble trying to compile GCC 2.7.2 with 
> NetBSD/Amiga due to what I am now certain is a subtle VM problem with the 
> Amiga kernel!  Please take the time to test this simple program on your 
> system and report to me (no need to copy to the NetBSD list) whether or 
> not it crashes).  Beware that it will eat up a certain amount of swap 
> space, 16MB should be adequate.  Thanks!
> This test program which will reliably segfault with i=174687, which
> you can verify with gdb on the core.  It creates 500,000 nodes in a chain,
> then traverses the chain, then recursively traverses the chain and frees
> the nodes in reverse order (it is when traversing the second time,
> searching for the end node, that it segfaults).  Considering the large
> number of nodes, it should give a good workout to the VM subsystem as well
> as malloc/free/sbrk.  It consistently crashes on my NetBSD/Amiga system.

The keyword here is recursive.  Recursive programs require a large 
amount of space to maintain each stack frame.  The reason why this 
program works for a smaller number of nodes is because there are very 
few stack frames involved--but increase to half a million nodes, then a 
recursive program requires such a staggering amount of stack compared to 
an iterative program doing the same thing.  So instead of giving the VM 
subsystem a workout, this is a stack exercise :-).  The problem has 
nothing to do with virtual memory.... or at least it shouldn't.  I 
havn't tested it on my system but how about this... if you're running CSH:

limit stackspace 65535

this will increase your stack from 8K to 64K.  This should solve your 
problem.  If this doesn't work, try:

unlimit stackspace

and run your program again.  The default stackspace csh gives to a 
program is 8K and with an application like yours, it seems like you're 
using up all your stack quite quickly.  When a program runs out of 
stack space, your program will try to read across a memory boundary, and 
this generates an error (segfault).... this can occur at any time the 
stack runs out so your program will segfault, and your counter i will 
contain the value at the time your program got the fault, but it won't 
TELL you anything because the memory bounds read occured in the stack...

Sometimes I dunno why they teach recursion in CS classes.  :*)

 o/ \o/  o  <o   o  o   o    She walks in  beauty, like the night
<|   |  /|\  |> <|><|> <|\       Of cloudless climes and starry skies;
/|  / \  /| / \ //  \\ / \   And all that's best of dark and bright
""""""""""""""""""""""""""""     Meet in her aspect and her eyes.  (Byron)