git: libc - Remove optimization that breaks malloc_usable_size() use cases
Matthew Dillon
dillon at crater.dragonflybsd.org
Mon Sep 7 14:09:36 PDT 2026
commit b4510a66558751a074cf6a0f30977b8639ce856f
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Mon Sep 7 14:02:42 2026 -0700
libc - Remove optimization that breaks malloc_usable_size() use cases
* The malloc implementation had an optimization meant to aid realloc()s
whereby unused portions of large memory blocks could be munmap()d.
However, lots of code uses the space returned by malloc_usable_size()
without calling realloc() to notify libc that additional space is being
used. Leading to segmentation faults.
* Original proposed solution to make malloc_usable_size() aware of a
prior munmap optimization does not completely fix the problem as excess
space may be unmapped after such calls as well as before.
* Removing the optimization and letting the pager deal with any actually-dead
excess space is the only option. So that is what we do.
Reported-by: Several people
Summary of changes:
lib/libc/stdlib/nmalloc.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/b4510a66558751a074cf6a0f30977b8639ce856f
--
DragonFly BSD source repository
More information about the Commits
mailing list