From owner-freebsd-questions@FreeBSD.ORG Sun Oct 5 21:28:44 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1A11B16A4B3 for ; Sun, 5 Oct 2003 21:28:44 -0700 (PDT) Received: from res241015.resnet.wsu.edu (res241015.resnet.wsu.edu [134.121.241.15]) by mx1.FreeBSD.org (Postfix) with ESMTP id 90DE143FCB for ; Sun, 5 Oct 2003 21:28:42 -0700 (PDT) (envelope-from james_jacobsen@lycos.co.uk) Received: from res241015.resnet.wsu.edu (localhost [127.0.0.1]) h964RqoG007942 for ; Sun, 5 Oct 2003 21:27:52 -0700 (PDT) (envelope-from james_jacobsen@lycos.co.uk) Date: Sun, 5 Oct 2003 21:27:51 -0700 From: James Jacobsen To: freebsd-questions@freebsd.org Message-ID: <20031006042751.GA85685@res241015.resnet.wsu.edu> References: <27DDB356-F790-11D7-9174-003065838A88@mulle-kybernetik.com> <20031006030656.GK5283@dan.emsphone.com> <16256.57227.924291.290786@jerusalem.litteratus.org> <20031006033200.GL5283@dan.emsphone.com> Mime-Version: 1.0 Content-Type: text/plain; Format=Flowed; DelSp=Yes; charset=ISO-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20031006033200.GL5283@dan.emsphone.com> (from dnelson@allantgroup.com on Sun, Oct 05, 2003 at 20:32:00 -0700) X-Mailer: Balsa 2.0.15 Lines: 45 Subject: Re: malloc() behavior (was: Pointer please) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Oct 2003 04:28:44 -0000 It does not matter what freebsd does, C does not require that malloc initialize space according to Kernighan and Ritchie. Its a good book, I would say its worth the forty dollars. --Will On 10/05/03 20:32:00, Dan Nelson wrote: > In the last episode (Oct 05), Robert Huff said: > > Dan Nelson writes: > > > Could be one of two problems. The program either malloced > memory > > > and tried to use it without zeroing it, or it freed some memory > > > and tried to keep using it. In -current, the malloc has the J > > > debugging flag set, which fills malloced and freed memory with > > > 0xd0 (see the malloc manpage). > > > > On that page (on my 5.1 system), it says malloc() does not > zero > > allocated pages. Is this a change (possibly just for CURRENT), and > > if so since when? Bexause unless I'm delusional (possible) I > thought > > pages /were/ supposed to be zeroed, and doing so was one of the > > system's "as time permits" chores. > > Pages handed to processes by the kernel are always zeroed, but pages > free()d then malloc()ed again are not zeroed by default on -RELEASEs, > because they usually aren't returned back to the kernel inbetween > (unless H is set, and even then it's not guaranteed). -CURRENT > always > has the J flag set, which means that any memory returned by malloc or > passed to free will get overwritten with 0xD0, to aid debugging. > That's not mentioned in the manpage, although I think it is mentioned > someplace else (either FAQ or handbook). > > -- > Dan Nelson > dnelson@allantgroup.com > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions- > unsubscribe@freebsd.org" > >