From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80977 invoked by alias); 18 Nov 2019 18:03:15 -0000 Mailing-List: contact libc-stable-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: List-Archive: Sender: libc-stable-owner@sourceware.org Received: (qmail 80967 invoked by uid 89); 18 Nov 2019 18:03:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: aloka.lostca.se Received: from aloka.lostca.se (HELO aloka.lostca.se) (178.63.46.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Nov 2019 18:03:13 +0000 Received: from aloka.lostca.se (aloka [127.0.0.1]) by aloka.lostca.se (Postfix) with ESMTP id 4055E15E78 for ; Mon, 18 Nov 2019 18:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=lostca.se; h=date:from:to :subject:message-id:mime-version:content-type :content-transfer-encoding; s=howrah; bh=/7NBm7/tfX9TL1e616Bc+5v G8uA=; b=1a337yNFwZEkwJgtEU9PIRRjpjGVy5RvcWD8Vdxdpesjy2N6wtTxxWa sDAluXlPP5NVp0q2wOM+jMd/HZ1gtITPywB/eQp6P2XwVTdAyiZ/kdB35evMBDFj duTerk2XBvEsTBcXy4EoQUvwQR3/cRgckBBo/fv17yiAn7la8TmA= Received: from localhost (unknown [IPv6:2a01:4f8:120:624c::25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aloka.lostca.se (Postfix) with ESMTPSA id EA49815E77 for ; Mon, 18 Nov 2019 18:03:10 +0000 (UTC) Date: Tue, 01 Jan 2019 00:00:00 -0000 From: Arjun Shankar To: libc-stable@sourceware.org Subject: [2.29 COMMITTED] malloc: Fix missing accounting of top chunk in malloc_info [BZ #24026] Message-ID: <20191118180309.GB73440@aloka.lostca.se> MIME-Version: 1.0 Content-Type: text/plain; charset=unknown-8bit Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-11/txt/msg00013.txt.bz2 Fixes ` incorrectly showing as 0 most of the time. The rest value being wrong is significant because to compute the actual amount of memory handed out via malloc, the user must subtract it from . That result being wrong makes investigating memory fragmentation issues like close to impossible. (cherry picked from commit b6d2c4475d5abc05dd009575b90556bdd3c78ad0) --- ChangeLog | 6 ++++++ malloc/malloc.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 95411e59a6..8bfc29a02f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-08-08 Niklas Hamb=C3=BCchen + Carlos O'Donell + + [BZ #24026] + * malloc/malloc.c (__malloc_info): Account for top chunk. + 2019-08-01 Florian Weimer =20 [BZ #24867] diff --git a/malloc/malloc.c b/malloc/malloc.c index f1e5eb878a..5c44dcdb66 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -5433,6 +5433,12 @@ __malloc_info (int options, FILE *fp) =20 __libc_lock_lock (ar_ptr->mutex); =20 + /* Account for top chunk. The top-most available chunk is + treated specially and is never in any bin. See "initial_top" + comments. */ + avail =3D chunksize (ar_ptr->top); + nblocks =3D 1; /* Top always exists. */ + for (size_t i =3D 0; i < NFASTBINS; ++i) { mchunkptr p =3D fastbin (ar_ptr, i); --=20 2.21.0