public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "toiwoton at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug malloc/26663] New: malloc() doesn't handle MALLOC_MMAP_THRESHOLD_=0 well
Date: Thu, 24 Sep 2020 13:36:49 +0000	[thread overview]
Message-ID: <bug-26663-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=26663

            Bug ID: 26663
           Summary: malloc() doesn't handle MALLOC_MMAP_THRESHOLD_=0 well
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: malloc
          Assignee: unassigned at sourceware dot org
          Reporter: toiwoton at gmail dot com
  Target Milestone: ---

Using environment variable MALLOC_MMAP_THRESHOLD_=0 may cause malloc() to fail
very easily. A case in point is startup of systemd-cryptsetup, which fails when
lvm2 library can't malloc() something
(https://github.com/lvmteam/lvm2/issues/39). This is probably a bug in kernel,
there's plenty of RAM available and I suppose the memory shouldn't ever be too
fragmented for page sized items.

But perhaps malloc() should use a better allocation strategy when mmap()ing,
for example mmap() larger areas at once, use them as arenas and deal them to
malloc() users as needed.

Maybe also when mmap() specifically fails with EAGAIN it could be retried a few
times. It looks like sysmalloc() only checks for MAP_FAILED
(https://sourceware.org/git?p=glibc.git;a=blob;f=malloc/malloc.c;h=cd9933b4e580a58a694ebf34e76ac6fecee29c14;hb=HEAD#l2330)
but not errno. Perhaps also some unused memory could be released by
munmap()ping unused parts of arenas etc. before retrying.

-Topi

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2020-09-24 13:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-24 13:36 toiwoton at gmail dot com [this message]
2020-09-24 14:53 ` [Bug malloc/26663] " carlos at redhat dot com
2020-09-24 15:20 ` toiwoton at gmail dot com
2020-09-24 15:55 ` toiwoton at gmail dot com
2020-09-24 16:42 ` carlos at redhat dot com
2024-01-11  9:39 ` fweimer at redhat 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-26663-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /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: link
Be 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).