[Bug malloc/26663] New: malloc() doesn't handle MALLOC_MMAP_THRESHOLD_=0 well
toiwoton at gmail dot com
sourceware-bugzilla@sourceware.org
Thu Sep 24 13:36:49 GMT 2020
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.
More information about the Glibc-bugs
mailing list