Subject: Argh - memory leaks in shells on NetBSD 1.0
To: None <current-users@NetBSD.ORG>
From: Sean Doran <smd@sprint.net>
List: current-users
Date: 05/17/1995 02:24:02
I'm having a problem with NetBSD-1.0 on a SPARCStation 2.

I built rc (ftp://viz.tamu.edu/rc/) version 1.4 (and also
1.5) with little difficult, and noticed after some time
that the RSS of running rc processes were enormously large.

After some tracking around I discovered several things:

	-- running  ps l$pid  in succession would show
	   an increase of 32 or more in the RSS each time
	-- running  ps l$pid | cat (or any other pipeline)
	   would increase the RSS by even more
	-- it didn't matter what compiled the binary;
	   the memory leak was not dependent on the compiler,
           which is what the rc maintainer types thought
	-- a binary built under SunOS 4.1.3_U1 and compiled
	   statically would not leak under SunOS, but
	   would leak under NetBSD
	-- /bin/sh (statically linked) from SunOS leaks under NetBSD

Things I haven't tested:

	statically linked /bin/csh or bash from SunOS
	bash as shipped, built on NetBSD (though I suppose
		Chet would have noticed any leak like this, yes?)
	other variants (mcsh, from der Mouse)

mostly due to frustration and business tempered with a bit of laziness.

The current hypothesis is that there may be a bug in
the sbrk system call or something wrong with the StunOS
compatibility code, however it clearly appears to be a
problem in the interaction between kernel and software,
rather than in the library or in the software itself.

I figure someone may know or recognize something I can't
see for myself.

Any help in squashing this memory leak so that I don't
see things like this:

UID   PID  PPID CPU PRI NI   VSZ  RSS WCHAN  STAT TT       TIME COMMAND
X    1935  1887   1  10  0   212 30988 wait   I+   p0    0:06.77 /bin/rc -i

would be *much* appreciated!

	Sean.