From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84117 invoked by alias); 19 Nov 2019 12:13:37 -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 84101 invoked by uid 89); 19 Nov 2019 12:13:36 -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=H*r:120 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; Tue, 19 Nov 2019 12:13:34 +0000 Received: from aloka.lostca.se (aloka [127.0.0.1]) by aloka.lostca.se (Postfix) with ESMTP id 868B31617B for ; Tue, 19 Nov 2019 12:13:32 +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=2BtH4HQJruNoS4OiF9029XH X1q0=; b=0ZBhARuWIMahYiHSw/HSk/3Le8EEj7K8An2lmu82EXHfFrRG6BNB5BI cGEbi7ifroJ29vYQSamrJHrngMYDEb+v32s/1xXFvpTzPNw9yvuvp+SUy79MNfOx Kifs33QOjX4G85z4h4q/ZwoWLmvAa2Uf4Csb994cWo2FJg/wbugo= 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 4B5911617A for ; Tue, 19 Nov 2019 12:13:32 +0000 (UTC) Date: Tue, 01 Jan 2019 00:00:00 -0000 From: Arjun Shankar To: libc-stable@sourceware.org Subject: [2.30 COMMITTED] malloc: Fix missing accounting of top chunk in malloc_info [BZ #24026] Message-ID: <20191119121331.GA89708@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/msg00018.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 43c9a70ed1..e1d8fd3c66 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-11-01 Dragan Mladjenovic =20 * sysdeps/unix/sysv/linux/mips/Makefile diff --git a/malloc/malloc.c b/malloc/malloc.c index 343d89f489..0e65d636cd 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -5406,6 +5406,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