[Bug 259076] pthread_mutex_init fails with limited AS
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 259076] pthread_mutex_init fails with limited AS"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 15 Oct 2021 17:59:11 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259076
--- 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() returns 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 == MAP_FAILED)
- pagepool_start = 0;
offset = (uintptr_t)pagepool_start - rounddown2(
(uintptr_t)pagepool_start, pagesz);
- pagepool_start = mmap(0, n * pagesz, PROT_READ | PROT_WRITE,
+ addr = mmap(0, n * pagesz, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, -1, 0);
- if (pagepool_start == MAP_FAILED) {
+ if (addr == MAP_FAILED) {
#ifdef IN_RTLD
rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": morepages: "
"cannot mmap anonymous memory: %s\n",
rtld_strerror(errno));
#endif
+ pagepool_start = pagepool_end = 0;
return (0);
}
+ pagepool_start = addr;
pagepool_end = pagepool_start + n * pagesz;
pagepool_start += offset;
--
You are receiving this mail because:
You are the assignee for the bug.