C Shells do not free memory; other quick C Shell bugs
idallen at watmath.UUCP
idallen at watmath.UUCP
Mon Jul 16 02:44:14 AEST 1984
From: phb at dcdwest.UUCP
Newsgroups: net.unix-wizards
Subject: Possible bug in 4.2 BSD csh
We have noticed a case where a csh shell script which contains a loop
that runs for many hours (sometimes, days even) accumulates all the
free memory on the system and causes the vax to brought to its knees
due to paging activity.
A simple such script is:
while ( 1 )
/bin/echo `date`
end
The C Shell does not free the GLOBbed argument list of a non-builtin
command if another GLOB non-builtin command immediately follows. You
get a new list every time, and the memory just grows until it's all
gone. (This thanks to vfork() and the child allocating the glob list
in the parent's address space without telling the parent how to free it
after the exec()!) Since the entire chain of allocated and free memory
blocks has to be searched to get the new memory, you touch a lot of
pages every time.
If you like to see other antisocial behaviour of the shell, try any of
the following quick bugs:
limit cputime 1.0e99
setenv USER 'xxxx*yyyy' ; /bin/csh
set xx='echo `echo hi`' ; eval $xx
set xx='echo `echo (`' ; eval $xx
date | if ( 1 ) /bin/echo The date is `cat`
sleep 60 && echo hi &
alias % anything ; alias
date ; exit ; echo I said EXIT dammit ; date ; date
( sleep 999 & ; jobs ; kill %% ; jobs ; jobs ; jobs )
You will also note that if you run a C Shell script and a command
returns a non-zero status, the shell will branch to byte 1024 of the file.
If the file isn't that long, the script terminates prematurely.
I'd go on, but 20 pages of C Shell bugs doesn't belong in this newsgroup.
Maybe I'll post it to net.sources some day.
--
-IAN! (Ian! D. Allen) University of Waterloo
More information about the Comp.unix.wizards
mailing list