Bug 1460043 - malloc_stats() should correctly represent large (>4GB) arenas.
malloc_stats() should correctly represent large (>4GB) arenas.
Status: NEW
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: glibc (Show other bugs)
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: glibc team
Depends On:
  Show dependency treegraph
Reported: 2017-06-08 18:32 EDT by Santosh
Modified: 2017-07-20 04:50 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Sourceware 21556 None None None 2017-06-09 02:53 EDT

  None (edit)
Description Santosh 2017-06-08 18:32:57 EDT
Description of problem:

In __malloc_stats(), mi.arena (defined as size_t) is cast to unsigned int, causing incorrect values to be displayed for > 4GB. 

   fprintf (stderr, "system bytes     = %10u\n", (unsigned int) mi.arena);
   fprintf (stderr, "in use bytes     = %10u\n", (unsigned int) mi.uordblks);

Version-Release number of selected component (if applicable):
Linux XXXXXX 2.6.32-573.12.1.el6.x86_64 #1 SMP Mon Nov 23 12:55:32 EST 2015 x86_64 x86_64 x86_64 GNU/Linux

LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.7 (Santiago)
Release:        6.7
Codename:       Santiago

Glib Version::

The above problem also exists in glib 2.25.
Comment 2 Carlos O'Donell 2017-06-08 18:56:14 EDT
Red Hat Enterprise Linux 6 is a production stage 3 OS and the kind of change you are suggesting is not suitable for this release. Instead I'm moving this bug to RHEL 7 where the problem is still present.

The public API which is relevant is malloc_stats(), and the result is cast to (int) because it's using mallinfo() internally and it only returns int sized results.

DJ Delorie (on the glibc team) is looking at mallinfo() (https://sourceware.org/ml/libc-alpha/2016-10/msg00142.html) to make it saturing. In the case of mallinfo we have a published API which only has type 'int' so we can't do any real fixes for mallinfo(). However, we might be able to get 'unsigned int' out of the interface e.g. up to 4GB (right now signed int is 2GB).

An even better solution for malloc_stats() exists, and that is to use size_t internally and print the values as correctly as possible, avoiding the use of mallinfo() internally.

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