From nobody Fri Oct 15 17:59:11 2021 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 99EF6180F490 for ; Fri, 15 Oct 2021 17:59:11 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HWDYC3vScz4smm for ; Fri, 15 Oct 2021 17:59:11 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6432729E6 for ; Fri, 15 Oct 2021 17:59:11 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 19FHxB4Y086167 for ; Fri, 15 Oct 2021 17:59:11 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 19FHxB7f086166 for bugs@FreeBSD.org; Fri, 15 Oct 2021 17:59:11 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 259076] pthread_mutex_init fails with limited AS Date: Fri, 15 Oct 2021 17:59:11 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: misc X-Bugzilla-Version: 13.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: kib@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D259076 --- Comment #9 from Konstantin Belousov --- (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.=