From owner-freebsd-current@FreeBSD.ORG Mon Oct 10 20:35:29 2005 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A118116A41F; Mon, 10 Oct 2005 20:35:29 +0000 (GMT) (envelope-from thompsa@freebsd.org) Received: from heff.fud.org.nz (60-234-149-201.bitstream.orcon.net.nz [60.234.149.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0D5543D49; Mon, 10 Oct 2005 20:35:28 +0000 (GMT) (envelope-from thompsa@freebsd.org) Received: by heff.fud.org.nz (Postfix, from userid 1001) id C90961CCDD; Tue, 11 Oct 2005 09:35:26 +1300 (NZDT) Date: Tue, 11 Oct 2005 09:35:26 +1300 From: Andrew Thompson To: Brooks Davis Message-ID: <20051010203526.GA1229@heff.fud.org.nz> Mail-Followup-To: Andrew Thompson , Brooks Davis , Yar Tikhiy , Pawel Jakub Dawidek , FreeBSD Current References: <20051005024903.GA72743@heff.fud.org.nz> <20051005203639.GA20552@garage.freebsd.pl> <20051005205515.GA30350@odin.ac.hmc.edu> <20051005210950.GB75848@heff.fud.org.nz> <20051009232849.GA27349@comp.chem.msu.su> <20051010022208.GA97249@heff.fud.org.nz> <20051010202900.GA24213@odin.ac.hmc.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051010202900.GA24213@odin.ac.hmc.edu> User-Agent: Mutt/1.4.2.1i Cc: Yar Tikhiy , Pawel Jakub Dawidek , FreeBSD Current Subject: Re: panic: ifc_free_unit: bit is already cleared 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: Mon, 10 Oct 2005 20:35:29 -0000 On Mon, Oct 10, 2005 at 01:29:00PM -0700, Brooks Davis wrote: > On Mon, Oct 10, 2005 at 03:22:08PM +1300, Andrew Thompson wrote: > > On Mon, Oct 10, 2005 at 03:28:49AM +0400, Yar Tikhiy wrote: > > > On Thu, Oct 06, 2005 at 10:09:50AM +1300, Andrew Thompson wrote: > > > > > > FWIW, I tried to look at the $subject problem since I had had it > > > before, but just got a different panic: > > > > > > Memory modified after free 0xc140b000(4092) val=deadc0dc @ 0xc140b000 > > > panic: Most recently used by clone > > > > > > The clone code seems to have decremented something (refcount?) twice > > > after freeing the memory chunk. > > > > I have been testing this patch and I think it fixes all the problems > > discussed. > > > > It changes refcounting to count the number of cloned interfaces so > > ifc_units is only freed when its safe. A new function has been added to > > decrement this when a simple cloner module is unloaded. The cloner is > > still detached first to prevent the race. > > > > In most cases the change is as simple as: > > while ((sc = LIST_FIRST(&gre_softc_list)) != NULL) { > > LIST_REMOVE(sc, sc_list); > > mtx_unlock(&gre_mtx); > > + ifc_simple_free(&gre_cloner, GRE2IFP(sc)); > > gre_destroy(sc); > > mtx_lock(&gre_mtx); > > } > > I don't see any reason why you can't just replace the specific destroy > calls with calls to ifc_simple_destroy(). That would avoid expanding > the API. I did experiment with that. On some interfaces it would cause the global mutex to be recursed, but that can be fixed. I'll have another go. Andrew