public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mtk.manpages at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sources.redhat.com Subject: [Bug libc/12129] New: mallop() M_MXFAST limit anomaly Date: Sun, 17 Oct 2010 14:33:00 -0000 [thread overview] Message-ID: <bug-12129-131@http.sourceware.org/bugzilla/> (raw) 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.
next reply other threads:[~2010-10-17 14:33 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-10-17 14:33 mtk.manpages at gmail dot com [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-12129-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sources.redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).