From owner-freebsd-current@FreeBSD.ORG Fri Apr 20 01:26:40 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 949ED16A408 for ; Fri, 20 Apr 2007 01:26:40 +0000 (UTC) (envelope-from sean-freebsd@farley.org) Received: from mail.farley.org (farley.org [67.64.95.201]) by mx1.freebsd.org (Postfix) with ESMTP id 62F2C13C46E for ; Fri, 20 Apr 2007 01:26:40 +0000 (UTC) (envelope-from sean-freebsd@farley.org) Received: from thor.farley.org (thor.farley.org [192.168.1.5]) by mail.farley.org (8.14.1/8.14.1) with ESMTP id l3K1RGvJ041193; Thu, 19 Apr 2007 20:27:16 -0500 (CDT) (envelope-from sean-freebsd@farley.org) Date: Thu, 19 Apr 2007 20:26:32 -0500 (CDT) From: "Sean C. Farley" To: Julian Elischer In-Reply-To: <46281223.8060800@elischer.org> Message-ID: <20070419201412.K45440@thor.farley.org> References: <20070419175902.R44041@thor.farley.org> <46281223.8060800@elischer.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-current@freebsd.org Subject: Re: Fix for memory leak in setenv/unsetenv (take 2) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Apr 2007 01:26:40 -0000 On Thu, 19 Apr 2007, Julian Elischer wrote: > Sean C. Farley wrote: >> I have a new patch that fixes memory leaks caused by repeated calls >> to setenv() with varying-sized values or unsetenv(). The web page >> has a better description about it. > > I vaguely remember that several people have tried to fix this before, > but that fixing it actually breaks some ABI.. I have been trying to fix it off and on since 2005[1]. :) I believe I have a change that does break the ABI. unsetenv(3) does not currently follow the standard by returning an int. I kept the void but recommend switching to an int. > I may be wrong but maybe others remember better what the issue was. > I believe that the end result was that it was considered better to leak > memory than break the posix specified ABI in some way. This patch still leaks memory in the sense that all calls to getenv() have valid pointers (non-freed) throughout the run of the program. It only cleans up when the library exits. Sean 1. http://lists.freebsd.org/pipermail/freebsd-hackers/2005-February/010463.html -- sean-freebsd@farley.org