Bug 27928 - mallinfo doc contains incorrect information about arenas
Summary: mallinfo doc contains incorrect information about arenas
Status: UNCONFIRMED
Alias: None
Product: glibc
Classification: Unclassified
Component: malloc (show other bugs)
Version: 2.33
: P2 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-28 13:17 UTC by crusaderky
Modified: 2021-06-02 07:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description crusaderky 2021-05-28 13:17:55 UTC
The mallinfo/mallinfo2 man and info pages state:

       Information is returned for only the main memory allocation area.   Al‐
       locations  in  other arenas are excluded.  See malloc_stats(3) and mal‐
       loc_info(3) for alternatives that include information about other  are‐
       nas.


This to me seems to be incorrect; by reading the source code I understand that mallinfo/mallinfo2 return the sum of all arenas ("Total" section in malloc_stats) and not just that of the main arena ("Arena 0" in malloc_stats).

On a related note, it would help to have the printf in malloc_stats tweaked to clarify that "Arena 0" is a synonym for the main arena.
Comment 1 Anna Lucca 2021-06-02 06:25:43 UTC Comment hidden (spam)
Comment 2 crusaderky 2021-06-02 07:54:40 UTC
The function shows the sum of all arenas - arena 0 + arena 1 + arena 2 + ...
The documentation says it only shows the "main" arena, or arena 0, which is the first one. This is not correct.