From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14883 invoked from network); 22 Nov 2007 02:57:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 22 Nov 2007 02:57:45 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 74532 invoked from network); 22 Nov 2007 02:57:33 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 22 Nov 2007 02:57:33 -0000 Received: (qmail 18808 invoked by alias); 22 Nov 2007 02:57:29 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24112 Received: (qmail 18791 invoked from network); 22 Nov 2007 02:57:28 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 22 Nov 2007 02:57:28 -0000 Received: (qmail 74138 invoked from network); 22 Nov 2007 02:57:28 -0000 Received: from g.primenet.com.au (203.24.36.10) by a.mx.sunsite.dk with SMTP; 22 Nov 2007 02:57:20 -0000 Received: (qmail 4700 invoked by uid 100); 22 Nov 2007 02:57:11 -0000 Date: Thu, 22 Nov 2007 13:57:11 +1100 From: Geoff Wing To: Zsh Hackers Subject: Re: PATCH: fix memory leak in new setenv code Message-ID: <20071122025711.GA4745@primenet.com.au> References: <2755.1193848735@dcle12> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2755.1193848735@dcle12> Organization: PrimeNet Computer Consultancy User-Agent: Mutt/1.5.17 (2007-11-01) On Thursday 2007-11-01 03:39 +1100, Oliver Kiddle output: :I noticed using Solaris libumem and mdb that zsh is leaking memory :every time an environment variable is modified. I traced this down to :some relatively recent change to use setenv(3) and the fact that the :old value was not being freed. I think the patch below is the correct :fix. : :Oliver : :--- Src/params.c.orig Wed Oct 31 17:30:57 2007 :+++ Src/params.c Wed Oct 31 17:28:49 2007 :@@ -3998,6 +3998,8 @@ : * the other branch? If so, we don't actually need to : * store pm->env at all, just a flag that the value was set. : */ :+ if (pm->env) :+ zsfree(pm->env); : pm->env = newenv; : #else : /* : This can't be right and corrupts my environment (using zsh memory routines). Running "env" spews out lots of bad stuff. If we're supposed to be zsfree()ing that, why aren't we doing it consistently, i.e. around the line which assigns newenv and before the call to zputenv()? Maybe it should be managed differently? Regards,