public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug malloc/26663] New: malloc() doesn't handle MALLOC_MMAP_THRESHOLD_=0 well
@ 2020-09-24 13:36 toiwoton at gmail dot com
  2020-09-24 14:53 ` [Bug malloc/26663] " carlos at redhat dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: toiwoton at gmail dot com @ 2020-09-24 13:36 UTC (permalink / raw)
  To: glibc-bugs

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.

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

end of thread, other threads:[~2024-01-11  9:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24 13:36 [Bug malloc/26663] New: malloc() doesn't handle MALLOC_MMAP_THRESHOLD_=0 well toiwoton at gmail dot com
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

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).