Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Oct 2021 17:59:11 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 259076] pthread_mutex_init fails with limited AS
Message-ID:  <bug-259076-227-cz6EHu1fXT@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-259076-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-259076-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D259076

--- Comment #9 from Konstantin Belousov <kib@FreeBSD.org> ---
(In reply to Denis Koreshkov from comment #8)
Why do not they help?  When mmap(2) returns MMAP_FAILED, morepages() return=
s 0.
Then, morecore would not touch pagepool_start.

Hmm, It is probably wrong that pagepool_end is not reset there.  I think I =
can
agree to some part of your note, that we should e.g. set both pagepool_start
and pagepool_end to 0 to avoid munmap(2)-ing something not own by us on the
next allocation attempt.

Like this (didn't tested)

diff --git a/libexec/rtld-elf/rtld_malloc.c b/libexec/rtld-elf/rtld_malloc.c
index 64218b5bb786..54159bec8e4e 100644
--- a/libexec/rtld-elf/rtld_malloc.c
+++ b/libexec/rtld-elf/rtld_malloc.c
@@ -271,21 +271,21 @@ morepages(int n)
                }
        }

-       if (pagepool_start =3D=3D MAP_FAILED)
-               pagepool_start =3D 0;
        offset =3D (uintptr_t)pagepool_start - rounddown2(
            (uintptr_t)pagepool_start, pagesz);

-       pagepool_start =3D mmap(0, n * pagesz, PROT_READ | PROT_WRITE,
+       addr =3D mmap(0, n * pagesz, PROT_READ | PROT_WRITE,
            MAP_ANON | MAP_PRIVATE, -1, 0);
-       if (pagepool_start =3D=3D MAP_FAILED) {
+       if (addr =3D=3D MAP_FAILED) {
 #ifdef IN_RTLD
                rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": morepages: "
                    "cannot mmap anonymous memory: %s\n",
                    rtld_strerror(errno));
 #endif
+               pagepool_start =3D pagepool_end =3D 0;
                return (0);
        }
+       pagepool_start =3D addr;
        pagepool_end =3D pagepool_start + n * pagesz;
        pagepool_start +=3D offset;

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-259076-227-cz6EHu1fXT>