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
Author: Ulrich Drepper <firstname.lastname@example.org>
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.
Upstream bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24026
Is it a bug positively? or have you just not send patch to upstream?
(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:
Author: Niklas Hamb�chen <email@example.com>
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
Already fixed in bug 1735747 in RHEL 8.2.0 as a last-minute addition.