From nobody Wed Dec 22 10:05:55 2021 X-Original-To: dev-commits-src-all@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 8A09B1905CB8; Wed, 22 Dec 2021 10:06:07 +0000 (UTC) (envelope-from git@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 4JJpqq5sfjz4YKl; Wed, 22 Dec 2021 10:05:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 C8E331B264; Wed, 22 Dec 2021 10:05:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BMA5tKL092006; Wed, 22 Dec 2021 10:05:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BMA5tWZ092005; Wed, 22 Dec 2021 10:05:55 GMT (envelope-from git) Date: Wed, 22 Dec 2021 10:05:55 GMT Message-Id: <202112221005.1BMA5tWZ092005@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 9185066430a0 - stable/12 - Temporarily disable libunwind's FrameHeaderCache, until there is a resolution for . List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9185066430a022a520dd8812dca34c8411c7e8aa Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640167560; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=igrYgHDp8zeaeeQueGI1PEsJLydRXN8VPxwc1yBuZKA=; b=scLC2lgCzWpblV33DJjmkJ4sCMXkAseWdBqbzx7ALYOInwqq+CH2I17bQNc4CkkBPN8JH6 6dkUzM/SfkQRi6qXedS6fYj+/cTiiJ0FY1zlPSsr8ls0IHrOy35qg+QUwrr+irjCD+c1QN YIbw5gwX53JjBZ/QVoJhgabWgkLh78CzYzW9Qh6O15GINUK2MMdvR/yxnGfjA7r6sQAOuE k2DGFMhL30yx4ajS5b+ePgGe6ZxZO6oINtz/DFR3zVfBRYDZHbougXP4xdLba4b9okg4sN bCmhFWUOFHloHuAFKvZqvYZT8CStutQE7ohtKgEWZS8JOY2Y+fVHnFjLIn+UxQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640167560; a=rsa-sha256; cv=none; b=q3mLmW0XkpPcb/CUMVl5Y1b0msC1JzOWKZLBNf8Kj4HMPQzmz7ZnuBxSOfg6kL5xVvY2i/ RzRv83CzwRAvCWeSCjarG6oTwsGp9XmYHo4edV+AZjwEV5+G8w2FPfsilok1xtnWHhRjla pOy9aE/deK0enoHX16sutKnIkA0azQxaZr43UWJm4CXanBZHdQ5oD903BrgIpTUQTIoZ07 LvNATFZyIy2GYOMheilJSv5j7JFoJobolRVHmhI86TI2sEfpO+6Aaj7UmI64PxHPW/VxCH 8gYwzse70s3TKylN2/XlGNaTNPl0i+qF0ZO/gIOryn0BcUOLYS2AoTQIowIhMQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=9185066430a022a520dd8812dca34c8411c7e8aa commit 9185066430a022a520dd8812dca34c8411c7e8aa Author: Dimitry Andric AuthorDate: 2020-08-15 22:58:07 +0000 Commit: Dimitry Andric CommitDate: 2021-12-22 09:58:28 +0000 Temporarily disable libunwind's FrameHeaderCache, until there is a resolution for . The cache implementation depends on dl_iterate_phdr(3) ensuring that its callbacks are not called simultaneously for multiple threads, but that is only the case for the dl_iterate_phdr() implementation in rtld. In a statically linked executable, libc's dl_iterate_phdr() is used, which does no such locking. If multiple threads then call into the unwinder at the same time, it is possible to trigger a segfault. In particular, the statically linked lld which is built during the cross-tools stage can segfault in this way, because it starts multiple worker threads that can exit in parallel. Since our pthread_exit(3) invokes the unwinder, it will therefore call into it in parallel too. (cherry picked from commit 9ff1cc58cd72f7109ae728ca32935cf9e8ca8ced) --- contrib/llvm-project/libunwind/src/AddressSpace.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/llvm-project/libunwind/src/AddressSpace.hpp b/contrib/llvm-project/libunwind/src/AddressSpace.hpp index a4564cb67328..d9d17ddb7bf4 100644 --- a/contrib/llvm-project/libunwind/src/AddressSpace.hpp +++ b/contrib/llvm-project/libunwind/src/AddressSpace.hpp @@ -452,10 +452,12 @@ struct _LIBUNWIND_HIDDEN dl_iterate_cb_data { #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." #endif +#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE) #include "FrameHeaderCache.hpp" // There should be just one of these per process. static FrameHeaderCache ProcessFrameHeaderCache; +#endif // _LIBUNWIND_USE_FRAME_HEADER_CACHE static bool checkAddrInSegment(const Elf_Phdr *phdr, size_t image_base, dl_iterate_cb_data *cbdata) { @@ -476,8 +478,10 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t pinfo_size, auto cbdata = static_cast(data); if (pinfo->dlpi_phnum == 0 || cbdata->targetAddr < pinfo->dlpi_addr) return 0; +#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE) if (ProcessFrameHeaderCache.find(pinfo, pinfo_size, data)) return 1; +#endif // _LIBUNWIND_USE_FRAME_HEADER_CACHE Elf_Addr image_base = calculateImageBase(pinfo); bool found_obj = false; @@ -505,7 +509,9 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t pinfo_size, found_obj = checkAddrInSegment(phdr, image_base, cbdata); } if (found_obj && found_hdr) { +#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE) ProcessFrameHeaderCache.add(cbdata->sects); +#endif // _LIBUNWIND_USE_FRAME_HEADER_CACHE return 1; } }