RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1661742 - glibc: malloc_info() returns wrong numbers
Summary: glibc: malloc_info() returns wrong numbers
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: glibc
Version: 8.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: glibc team
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On: 1819986
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-12-22 19:47 UTC by nh2
Modified: 2023-07-18 14:30 UTC (History)
9 users (show)

Fixed In Version: glibc-2.28-79.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-02 02:25:51 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Patch fixing missing accounting of top chunk (1.80 KB, application/mbox)
2018-12-22 19:47 UTC, nh2
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-35813 0 None None None 2021-09-17 12:23:40 UTC
Sourceware 24026 0 P2 RESOLVED malloc_info() returns wrong numbers 2020-04-02 02:18:08 UTC

Description nh2 2018-12-22 19:47:30 UTC
Created attachment 1516273 [details]
Patch fixing missing accounting of top chunk

glibc's malloc_info() function returns wrong numbers in most of the cases.

In particular, the `rest` field is 0 most of the time, and inconsistent with malloc_stats().

I believe this bug was introduced in commit

    commit bb066545063246d6df186f5a5a61303c58c6547d
    Author: Ulrich Drepper <drepper>
    Date:   Thu Apr 9 05:45:42 2009 +0000
    
        * malloc/malloc.c (malloc_info): New function.

when the implementation of malloc_info() was copy-pasted from mallinfo(), and that the two mallinfo() lines

+      avail = chunksize (ar_ptr->top);
+      nblocks = 1;  /* top always exists */

were forgotten to be copy-pasted.

I have attached a patch that fixes the issue.

Comment 1 nh2 2018-12-22 19:52:36 UTC
Upstream bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24026

Comment 3 baul 2019-06-02 09:10:21 UTC
Is it a bug positively? or have you just not send patch to upstream?

Comment 4 Carlos O'Donell 2019-10-01 19:21:12 UTC
(In reply to baul from comment #3)
> Is it a bug positively? or have you just not send patch to upstream?

It's a bug.

Fixed with this patch:

commit b6d2c4475d5abc05dd009575b90556bdd3c78ad0
Author: Niklas Hamb�chen <mail>
Date:   Thu Aug 8 22:02:27 2019 +0200

    malloc: Fix missing accounting of top chunk in malloc_info [BZ #24026]
    
    Fixes `<total type="rest" size="..."> 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 <system type="current" size="...">. That result being wrong
    makes investigating memory fragmentation issues like
    <https://bugzilla.redhat.com/show_bug.cgi?id=843478> close to
    impossible.

Comment 6 Carlos O'Donell 2020-04-02 02:25:51 UTC
Already fixed in bug 1735747 in RHEL 8.2.0 as a last-minute addition.


Note You need to log in before you can comment on or make changes to this bug.