public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12129] New: mallop() M_MXFAST limit anomaly
@ 2010-10-17 14:33 mtk.manpages at gmail dot com
  2010-10-17 15:14 ` [Bug libc/12129] " drepper.fsp at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: mtk.manpages at gmail dot com @ 2010-10-17 14:33 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12129

           Summary: mallop() M_MXFAST limit anomaly
           Product: glibc
           Version: 2.12
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: mtk.manpages@gmail.com
                CC: wg@malloc.de


After the call mallopt(M_MXFAST, n), the user might expect that requests of up
to "n" bytes are allocated from fastbins. However, to ensure that requests of
size "n" are allocated from fastbins, it is necessary (on 32-bit) to make a
call of the form

malloc(M_MXFAST, ((n + 3) & ~7) + 4);

So, for example, to allocate blocks of size 29 bytes from fastbins, one must
make a mallopt() call where the argument is at least 36:

mallopt(M_MXFAST, 36);

The problem occurs because
1) When setting the M_MXFAST limit (set_max_fast()), the limit is rounded up
according to the formula:
(n + SIZE_SZ) & ~MALLOC_ALIGN_MASK)
2) The size required for malloc() allocations is rounded up according to the
formula:
(n + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK

Possibly, the fix is as simple as redefining set_max_fast() as follows:

#define set_max_fast(s) \
  global_max_fast = (((s) == 0)        \
               ? SMALLBIN_WIDTH
               : ((s + SIZE_SZ - 1) & ~MALLOC_ALIGN_MASK) + SIZE_SZ)

However, I have not considered the implications of that change in detail.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-06-30 17:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-17 14:33 [Bug libc/12129] New: mallop() M_MXFAST limit anomaly mtk.manpages at gmail dot com
2010-10-17 15:14 ` [Bug libc/12129] " drepper.fsp at gmail dot com
2010-10-24  7:56 ` [Bug libc/12129] mallopt() " mtk.manpages at gmail dot com
2011-01-26  0:55 ` LpSolit at netscape dot net
2012-03-29  4:39 ` mtk.manpages at gmail dot com
2013-03-17 17:31 ` carlos at redhat dot com
2013-04-15  9:35 ` [Bug malloc/12129] " siddhesh at redhat dot com
2014-06-30  7:48 ` fweimer at redhat dot com
2021-06-30 17:01 ` maxkamper at outlook dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).