From owner-freebsd-hackers@FreeBSD.ORG Wed Jul 30 19:20:21 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 02157B5D for ; Wed, 30 Jul 2014 19:20:21 +0000 (UTC) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AFF732931 for ; Wed, 30 Jul 2014 19:20:20 +0000 (UTC) Received: by mail-vc0-f175.google.com with SMTP id ik5so2597636vcb.34 for ; Wed, 30 Jul 2014 12:20:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=3Jy5DcualqOcwSb0HiWeBhF9aodT1/CD5ni4yCBUwPM=; b=EQwNRmOuQJKNpnXuGoMv8XFCYYBo8jQ5GwbNaeVAozJSaXesAOBz2cfs0VCVL9+vPr DY+UAHcO5y8/mVKOitIdxtES23itCw4OGckt0eq2iNtcHYY0ii2gB7jaZgPOJVejX7Lu mz3J8Sj/ip60mTMvHyVp5mK7gRdXZ7SE+UfTD2uHVtq5iZV1p2Ir2ShnP0WWO2KhQ40P 7gJ99QrSQq0zzs/bB+B3TDWuZJ5OTGy3CVU/tfAjVVybgaHi3HdCKwUfQDIrJRWxFxNY tq/LjFtmfHGBhp8QMDb7fMU4VPl06FK2NjIxQrdjCNuu1ubsr8pu7RMP1oRBQzYAJSyB cS9A== X-Gm-Message-State: ALoCoQlcOqPa3Wh5hsQQSAPHUisZC2r6cZPesmJPwYkzTfSEXgUcw8zmEqwm+b3J59HQcGlXh0k5 X-Received: by 10.52.38.67 with SMTP id e3mr10459659vdk.56.1406748013486; Wed, 30 Jul 2014 12:20:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.58.220.66 with HTTP; Wed, 30 Jul 2014 12:19:53 -0700 (PDT) X-Originating-IP: [216.240.30.23] In-Reply-To: <20140728202156.GB9781@dft-labs.eu> References: <20140728191950.GA9781@dft-labs.eu> <20140728202156.GB9781@dft-labs.eu> From: Bryan Venteicher Date: Wed, 30 Jul 2014 14:19:53 -0500 Message-ID: Subject: Re: Allocation/free history To: Mateusz Guzik , suresh gumpula , "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 19:20:21 -0000 On Mon, Jul 28, 2014 at 3:21 PM, Mateusz Guzik wrote: > On Mon, Jul 28, 2014 at 03:37:28PM -0400, suresh gumpula wrote: > > Hi, > > I am aware of redone(9). I am talking about PC allocation history of > > objects. Do we have something like that ? > > > > Well, redzone "remembers" allocation and free backtrace, but does not > keep any further history. It is unclear for me if tracking entire > history would be of much benefit (note that mere allocation instruction > pointer is typically not really helpful and keeping bts for everything > would be quite memory consumimg). > > =E2=80=8BThe AIX kernel debugger can provide a history when and who allocat= ed and freed a piece of memory. In a previous life, this was very useful at times to track down memory corruption issues. Stealing a random example from [1]: (0)> xm -h 0x09410200 *Display debug xmalloc records associated with addr* 0B78DAB0: addr......... 09410200 req_size..... 128 freed unpinned 0B78DAB0: pid.......... 00043158 comm......... bcross Trace during xmalloc() Trace during xmfree() 002329E4(.xmalloc+0000A8) 002328F0(.xmfree+0000FC) 00235CD4(.dlistadd+000040) 00234F04(.setbitmaps+0001BC) 00235520(.newblk+00006C) 00236894(.finicom+0001A4) 0B645120: addr......... 09410200 req_size..... 128 freed unpinned 0B645120: pid.......... 0007DCAC comm......... bcross Trace during xmalloc() Trace during xmfree() 002329E4(.xmalloc+0000A8) 002328F0(.xmfree+0000FC) 00235CD4(.dlistadd+000040) 00236614(.logdfree+0001E8) 00236574(.logdfree+000148) 00236720(.finicom+000030) [1] - http://www.mouritzen.dk/aix-doc/en_US/a_doc_lib/aixprggd/kernextc/kdb_cmd17= .htm > > Thanks > > Suresh > > > > > > On Mon, Jul 28, 2014 at 3:19 PM, Mateusz Guzik > wrote: > > > > > On Mon, Jul 28, 2014 at 01:40:10PM -0400, suresh gumpula wrote: > > > > Hi, > > > > Knowing the PC of an allocation is very usefull in debugging. > Having > > > the > > > > PC hash table and storing the pc hash either with an object itself= ( > at > > > the > > > > end) or allocate an exra structure to hold the > > > > hash index help us find out who/where an object was allocated. W= e > > > > already have something like this in our own operating system and ha= s > > > been a > > > > useful thing in debugging. > > > > BSD allocator uses power of 2, so storing at the end of an object > might > > > be > > > > wasting lot of memory with large objects. > > > > > > > > It appears we don=E2=80=99t have something like this in current FBS= D > codeline and > > > > would like to work on this ? Any comments please? > > > > > > > > > > > > It would be something like below. 8 bytes at the end of each object > has > > > > fecepost which is usefull in finding overwrites and 2 hash indices > to the > > > > PC table to track allocation history. > > > > (kgdb-amd64-7.4-87) x/40w 0xffffff153728b038 > > > > 0xffffff153728b038: 0xf6970a05 0x06cb7e0c 0x305a134a > > > > 0x831c18bb > > > > 0xc0000bed 0x134a2115 > > > > > > > > 0xffffff153728b050: 0x85687ef8 0xffffffff 0x00000001 > > > > 0x83192201 > > > > 0xc0000bed 0x1741143b > > > > > > > > > > See redzone(9). > > > > > > -- > > > Mateusz Guzik > > > > > -- > Mateusz Guzik > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org= " >