From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15333 invoked from network); 25 Apr 2004 20:45:47 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 25 Apr 2004 20:45:47 -0000 Received: (qmail 2578 invoked by alias); 25 Apr 2004 20:45:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19831 Received: (qmail 2523 invoked from network); 25 Apr 2004 20:45:35 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 25 Apr 2004 20:45:35 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 25 Apr 2004 20:45:35 -0000 Received: (qmail 8485 invoked from network); 25 Apr 2004 20:45:35 -0000 Received: from wbar3.sjo1-4-11-009-147.sjo1.dsl-verizon.net (HELO candle.brasslantern.com) (4.11.9.147) by a.mx.sunsite.dk with SMTP; 25 Apr 2004 20:45:32 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id i3PKjUw25793; Sun, 25 Apr 2004 13:45:30 -0700 X-Authentication-Warning: candle.brasslantern.com: schaefer set sender to schaefer@closedmail.com using -f From: Bart Schaefer Message-Id: <1040425204530.ZM25792@candle.brasslantern.com> Date: Sun, 25 Apr 2004 20:45:30 +0000 In-Reply-To: <20040425013647.GA28395@scowler.net> Comments: In reply to Clint Adams "Re: Bug#245678: zsh: built-in rm -rf fills up the memory" (Apr 24, 9:36pm) References: <20040424162150.GA4210@ay.vinc17.org> <20040425013647.GA28395@scowler.net> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: Re: Bug#245678: zsh: built-in rm -rf fills up the memory Cc: 245678-forwarded@bugs.debian.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Flag: YES X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: ****** X-Spam-Status: Yes, hits=6.3 required=6.0 tests=BAYES_20,RCVD_IN_DYNABLOCK, RCVD_IN_NJABL,RCVD_IN_NJABL_DIALUP,RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 6.3 X-Spam-Report: * -1.4 BAYES_20 BODY: Bayesian spam probability is 20 to 30% * [score: 0.2499] * 3.5 RCVD_IN_NJABL_DIALUP RBL: NJABL: dialup sender did non-local SMTP * [4.11.9.147 listed in dnsbl.njabl.org] * 2.6 RCVD_IN_DYNABLOCK RBL: Sent directly from dynamic IP address * [4.11.9.147 listed in dnsbl.sorbs.net] * 0.1 RCVD_IN_NJABL RBL: Received via a relay in dnsbl.njabl.org * [4.11.9.147 listed in dnsbl.njabl.org] * 1.5 RCVD_IN_SORBS RBL: SORBS: sender is listed in SORBS * [4.11.9.147 listed in dnsbl.sorbs.net] On Apr 24, 9:36pm, Clint Adams wrote: } } I can reproduce the memory consumption with a 7210-file Maildir, except } that my kernel does the right thing and kills the runaway zsh. } } If I abort the rm before it OOMs, zsh will continue to take up a large } amount of memory until it exits. There's got to be something here you're not telling us. Either there is an alias for "rm", or a function named "rm", or the zsh/files module is loaded; otherwise "rm" and "/bin/rm" should be equivalent (assuming there is no other "rm" in the path) and in any case shouldn't execute inside the shell. Assuming that it's the zsh/files module, the interesting thing there is that, because it's a depth-first traversal, it allocates zsh-heap memory to store all the file names in the directory, and it does so by growing the allocated heap block once for each filename, by the length of that filename (plus one). If ZSH_MEM was not defined at compile time, doing this efficiently is left up to the underlying malloc() implementation [if I'm reading mem.c correctly] and therefore could be subject to bugs we've seen before where malloc never reclaims nor consolidates blocks when the implementation repeatedly realloc()s in slightly larger chunks. I don't know anything about how zsh is compiled on debian or even why the zsh/files module would be used (seemingly) by default, but in that's probably the place to start looking.