Subject: out of memory locks my terminal up
To: None <netbsd-help@netbsd.org>
From: James Wetterau <jwjr@name.net>
List: netbsd-help
Date: 09/30/1998 16:41:08
So I recently installed (helped Perry Metzger install?) 1.3.2 on my PC
at my home.  On the whole I'm quite happy.  Life is good.  I struggled
a little with XFree86, but installing perl and samba and ssh and X
itself was a snap.

Until just now.

For a couple of days now I've been running Don Mitchell and Matt
Blaze's truerand program version 2.1, a hack which uses clock skew as
a source of noise to generate random numbers, piling up my personal
random number collection.  I was happy to see that though the truerand
README warned of its only having been tested with SunOS 4.1.3 and
BSDI, it compiled without warnings even and seemed to work pretty
well.  Since my machine had precious little else to do, except act as
a NAT box for my LAN at home, I left truerand running.  You never know
when you'll need lots and lots of 32-bit random numbers, and I have
diskspace aplenty.

Now, just recently a guy here where I'm working (in a different city
from my machine) asked me what the distribution of the random numbers
was.  It occurred to me that since I now have about 100,000 of them it
would be a good time to verify their distribution frequency.  So I
wrote a little perl script to slice the range 0 - 2^32 into 50 parts
and print out a simple ASCII frequency graph. 

Unfortunately, I experienced a problem I've often experienced with
perl; ballooning data structures.  It's easy to forget that the reason
perl can do such nifty and quick things without caring about memory
allocation or types, such as treating strings as numbers where
appropriate and vice versa, is that it throws lots and lots of memory
at the problem, pre-allocating aggressively.  And so, the perl
program, working on and sorting about 1MB of string input representing
about 10^ 5 unsigned ints, grew to use over 32MBs of memory in the
resident set.  Just at the moment I was thinking it might be prudent
to kill the process and re-write the script my terminal hung.

I'm now no longer able to log into my machine.  (RSA authenticated Ssh
is the only access method I permit).  I can ping it just fine, but
it's well and truly wedged.  I'll be able to talk my SO through the
process of unwedging the machine (the things we do for love!) but I'm
curious why this happened.

Any ideas?

All the best,
James Wetterau