From owner-freebsd-current@FreeBSD.ORG Mon Sep 1 14:04:06 2003 Return-Path: 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 5E19D16A4BF for ; Mon, 1 Sep 2003 14:04:06 -0700 (PDT) Received: from heron.mail.pas.earthlink.net (heron.mail.pas.earthlink.net [207.217.120.189]) by mx1.FreeBSD.org (Postfix) with ESMTP id BDC1B43FDD for ; Mon, 1 Sep 2003 14:04:05 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from user-38ldup2.dialup.mindspring.com ([209.86.251.34] helo=mindspring.com) by heron.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 19tvpl-0006tV-00; Mon, 01 Sep 2003 14:03:34 -0700 Message-ID: <3F53B3EF.2DC9F755@mindspring.com> Date: Mon, 01 Sep 2003 14:02:39 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Pawel Jakub Dawidek References: <20030831070854.GA54748@panzer.kdm.org> <20030901064840.GA61253@panzer.kdm.org> <20030901103016.GI47959@garage.freebsd.pl> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a46b5862f011f5f1bac3be32df2f85d759667c3043c0873f7e350badd9bab72f9c350badd9bab72f9c cc: Poul-Henning Kamp cc: "Kenneth D. Merry" cc: current@FreeBSD.org Subject: Re: need some debugging help X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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, 01 Sep 2003 21:04:06 -0000 Pawel Jakub Dawidek wrote: > On Mon, Sep 01, 2003 at 12:48:41AM -0600, Kenneth D. Merry wrote: > +> - I tried just holding a mutex all the time, but obviously you can't > +> malloc while holding a mutex (except Giant), and the sysctl code does a > +> number of mallocs. (The original cause of this problem -- M_WAITOK > +> mallocs.) > > I've proposed some time ago changing M_WAITOK to M_NOWAIT, because > function/macros responsible for sysctl creation could failed from other > reasons, so I don't see any reason why they couldn't fail because of > insufficient memory. Caller is obliged to check return value... M_WAITOK is obliged to wait for fricking ever if it can't allocate the memory, rather than failing and returning a NULL pointer that then gets dereferenced because the function returned when the code expected the traditional M_WAITOK semantics. In other words, this problem derives from a semantics change, not from any actual bug. If you don't like it, then you need to change every instance of a call to malloc with M_WAITOK to check its return value before using it. Doing this does'nt require introducing yet another semantic. -- Terry