[Bug 259076] pthread_mutex_init fails with limited AS

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 11 Oct 2021 16:13:00 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259076

Konstantin Belousov <kib@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kib@FreeBSD.org

--- Comment #1 from Konstantin Belousov <kib@FreeBSD.org> ---
Yes, I think something along these lines should help.
Can you confirm?

diff --git a/libexec/rtld-elf/rtld_malloc.c b/libexec/rtld-elf/rtld_malloc.c
index 6604aa7201f8..61c18abb0d49 100644
--- a/libexec/rtld-elf/rtld_malloc.c
+++ b/libexec/rtld-elf/rtld_malloc.c
@@ -184,7 +184,9 @@ morecore(int bucket)
                nblks = 1;
        }
        if (amt > pagepool_end - pagepool_start)
-               if (morepages(amt/pagesz + NPOOLPAGES) == 0)
+               if (morepages(amt / pagesz + NPOOLPAGES) == 0 &&
+                   /* Retry with min required size */
+                   morepages(amt / pagesz) == 0)
                        return;
        op = (union overhead *)pagepool_start;
        pagepool_start += amt;

-- 
You are receiving this mail because:
You are the assignee for the bug.