From owner-freebsd-hackers Tue May 22 14:27:55 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from pike.osd.bsdi.com (pike.osd.bsdi.com [204.216.28.222]) by hub.freebsd.org (Postfix) with ESMTP id 6E4B237B422; Tue, 22 May 2001 14:27:51 -0700 (PDT) (envelope-from jhb@foo.osd.bsdi.com) Received: from foo.osd.bsdi.com (root@foo.osd.bsdi.com [204.216.28.137]) by pike.osd.bsdi.com (8.11.1/8.9.3) with ESMTP id f4MLRmK50014; Tue, 22 May 2001 14:27:48 -0700 (PDT) (envelope-from jhb@foo.osd.bsdi.com) Received: (from jhb@localhost) by foo.osd.bsdi.com (8.11.1/8.11.1) id f4MLRlu42407; Tue, 22 May 2001 14:27:47 -0700 (PDT) (envelope-from jhb) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200105222112.f4MLCh610392@earth.backplane.com> Date: Tue, 22 May 2001 14:27:47 -0700 (PDT) From: John Baldwin To: Matt Dillon Subject: Re: RE: vmspace leak (+ tentative fix) Cc: "Brian F. Feldman" , hackers@FreeBSD.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 22-May-01 Matt Dillon wrote: > >: >: >:On 22-May-01 Matt Dillon wrote: >:>:Ok, then why not let the current shmexit() stay in exit1() as a hack to >:>:help >:>:free memory, but add in a check in vmspace_free() as well to catch any race >:>:conditions that may fall through the cracks? As long as we clear the shm >:>:pointer in struct vmspace when we free it then we won't be double free'ing, >:>:and >:>:will always free it eventually. That is also a much simpler change. :) >:>:Additionally, adding to the comment in exit1() clarifying that this is an >:>:attempt to free resources as soon as possible and that the race condition >:>:is >:>:known and that vmspace_free() is a catch-all might be nice as well. >:>: >:>:-- >:>: >:>:John Baldwin -- http://www.FreeBSD.org/~jhb/ >:>:PGP Key: http://www.baldwin.cx/~john/pgpkey.asc >:> >:> It's not really good programming practice. Someone might trip over >:> it later on. >: >:Then the vmspace free()ing is also bad programming practice? It's the same >:exact algorithm used for the vmspace. >: >:> -Matt >: >:John Baldwin -- http://www.FreeBSD.org/~jhb/ > > Huh? It doesn't look like the same algorithm to me. In exit1() we attempt to free resources early if we can. If we lose the race, we still clean it up in vmspace_free() called from cpu_wait(). If you check the shm pointer and do shmexit() in vmspace_free() just as is done in vmspace_free(), then you will catch any cases that fall through with the shm not being free'd using the same technique currently employed in releasing the vmspace and with a minimal amount of change to the code. -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.Baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message