From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 28 19:20:02 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 1217A381 for ; Mon, 28 Jul 2014 19:20:02 +0000 (UTC) Received: from mail-wg0-x22a.google.com (mail-wg0-x22a.google.com [IPv6:2a00:1450:400c:c00::22a]) (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 9BE782653 for ; Mon, 28 Jul 2014 19:20:01 +0000 (UTC) Received: by mail-wg0-f42.google.com with SMTP id l18so7746652wgh.25 for ; Mon, 28 Jul 2014 12:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=U6mC3Bjqx2uCqAmWvbeHB7Cof8k57z9WsIHQpEAdDwY=; b=b+NfJSbTZSO1PXX0gk+nDTXom4QEWex/3QP3o2Xj9IHJdQwkU+oKkjP2S2l27ZVnnC 14pHcyv89LWL7c6LAfPYpajHZIt3YxbIE+rUh9tbwfoC9YI9liqDcDPbQzQ6fmCy5C8U 6xAEyIWfPWj0tObDS4vl3/55f/6FcdwCrY9p2kILmg38N4OvLmfH6qRG7BuPLZBmE/No AEnWrXElf6fSyDyghhxyamMSYC7ksym1t5nCUzIj+sfkXsGWLQJ4QjYpB4pACLfk+qBo 2ech1tpmap+uz+T5WFU6jB0Yop4fq1IN7fH/Eje+zCbekXjCJG2vLUYhymzsxVlFFZVc zoVQ== X-Received: by 10.180.95.66 with SMTP id di2mr28698051wib.60.1406575196254; Mon, 28 Jul 2014 12:19:56 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id sa4sm51580317wjb.45.2014.07.28.12.19.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 28 Jul 2014 12:19:55 -0700 (PDT) Date: Mon, 28 Jul 2014 21:19:51 +0200 From: Mateusz Guzik To: suresh gumpula Subject: Re: Allocation/free history Message-ID: <20140728191950.GA9781@dft-labs.eu> Mail-Followup-To: Mateusz Guzik , suresh gumpula , freebsd-hackers@freebsd.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-hackers@freebsd.org 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: Mon, 28 Jul 2014 19:20:02 -0000 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. We > already have something like this in our own operating system and has 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’t have something like this in current FBSD 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