From nobody Mon Jun 10 07:29:41 2024 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 4VyNjd71glz5P6PR; Mon, 10 Jun 2024 07:29:41 +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 4VyNjd6RR3z4tGm; Mon, 10 Jun 2024 07:29:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718004581; 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=t8rKw+E+6oY66WW+1N1ap+zzhAG6fu7eBBgW/m60YFM=; b=JKDgURss5ibphkwqTNww+5kMIZtRp5lfnC3AiMlxeroRVHtmJamXUVIgGvaLC8Hf4w4S6p gyBarfzn7V40dJCXQ8B8wX7DjdUVgHy1+WDv12XukPVrEW1Jaaqqb5VLVe5T2MlI8DC6HY y+Tcrjv7hXfw2vdddMhA3JNejCXozSu3enWXPrD7iMrtYHLsHyQhuniHByIKcEmFkDEls7 3ZUIYiUUvPXrCEP1VZ2uHs2TaQhiqyd98H0nVKAoNEET1UxtI++piQd8AWY5eYSnHbDbXs HBA2runleKSFvUMd6ojr0yo9AZ4Yfi5PJnttnrbw1ulJvi9fd07DK8yAm/IOSw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718004581; a=rsa-sha256; cv=none; b=Vnj9Fh2/9o2fBedEIV1DkpLZDTm8tO3LTdL1rW1rZS0Gl9iFjZvNDZT37sgGkbm/QRIRmx ngWfJtaQ4QLHBdcJXHubx6VPZg3QcObu/wBtRKIhxyVENGZbOzW7xXOho0p4fp5g3kX3fC sp0LAAMn3Fmr+ZSl/h0x/nGK7VYForliNGDwbBWOuawQZ28FzzdqhEqgZ+SLw97cuWXjPT szy52MDCorI3lKbtCu7tNTS6B/wRyvBIrAzxKm7aNU4POqxvYKUQxQ5Xe7HGzIiHCLnIvo WIMEd4H5JUe7dKyQavF3VahVS/9wqmahBuJ+fHEKCNnDI2s0oQXwMCmF4eQZBQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718004581; 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=t8rKw+E+6oY66WW+1N1ap+zzhAG6fu7eBBgW/m60YFM=; b=iprE0FPpxcYM2N5TpgF/9J0Mq1FW/fJKY1sBtbL1rz8dOQkILU+KRKfdGPyCv17DZuxSxi datrxwAqqllp2T7stXtXfsOj65Ccpn1TbZabyZMcyJKawnaaLpZer6p6KnZ82O9GPn2XDP fNHqKmB9KZvF6o+t3OPQ/PafGgPlvc6Pnv/TU1X1E3+aha3876rGrXtYZT3R/Yd9Be74/x 8a018MRlNCKmtDg1istP1PH9Hxt8YvjtspCxCXWbJXXZY4gPI+r3Xt80JLlykxabtRMNlj vH1TzxqHoUiXUgistRvP6CbQWFknV+f8+Mf5EuQ3v4X5n1dI93AZdDEc7QCrJw== 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 4VyNjd5wftzGrS; Mon, 10 Jun 2024 07:29:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45A7TfI6027948; Mon, 10 Jun 2024 07:29:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45A7TfcU027946; Mon, 10 Jun 2024 07:29:41 GMT (envelope-from git) Date: Mon, 10 Jun 2024 07:29:41 GMT Message-Id: <202406100729.45A7TfcU027946@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: 55c5dad2f305 - stable/14 - Merge commit 382f70a877f0 from llvm-project (by Louis Dionne): 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/14 X-Git-Reftype: branch X-Git-Commit: 55c5dad2f305f74d1ff5ca85c453635511aab9b2 Auto-Submitted: auto-generated The branch stable/14 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=55c5dad2f305f74d1ff5ca85c453635511aab9b2 commit 55c5dad2f305f74d1ff5ca85c453635511aab9b2 Author: Dimitry Andric AuthorDate: 2024-06-07 18:42:53 +0000 Commit: Dimitry Andric CommitDate: 2024-06-10 07:29:25 +0000 Merge commit 382f70a877f0 from llvm-project (by Louis Dionne): [libc++][NFC] Rewrite function call on two lines for clarity (#79141) Previously, there was a ternary conditional with a less-than comparison appearing inside a template argument, which was really confusing because of the <...> of the function template. This patch rewrites the same statement on two lines for clarity. Merge commit d129ea8d2fa3 from llvm-project (by Vitaly Buka): [libcxx] Align `__recommend() + 1` by __endian_factor (#90292) This is detected by asan after #83774 Allocation size will be divided by `__endian_factor` before storing. If it's not aligned, we will not be able to recover allocation size to pass into `__alloc_traits::deallocate`. we have code like this ``` auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); __p = __allocation.ptr; __set_long_cap(__allocation.count); void __set_long_cap(size_type __s) _NOEXCEPT { __r_.first().__l.__cap_ = __s / __endian_factor; __r_.first().__l.__is_long_ = true; } size_type __get_long_cap() const _NOEXCEPT { return __r_.first().__l.__cap_ * __endian_factor; } inline ~basic_string() { __annotate_delete(); if (__is_long()) __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); } ``` 1. __recommend() -> even size 2. `std::__allocate_at_least(__alloc(), __recommend(__sz) + 1)` - > not even size 3. ` __set_long_cap() `- > lose one bit of size for __endian_factor == 2 (see `/ __endian_factor`) 4. `__alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap())` -> uses even size (see `__get_long_cap`) This should fix incorrect deallocation sizes for some instances of std::string. Memory profiling or debugging tools like AddressSanitizer, LeakSanitizer or TCMalloc could then complain about the the size passed to a deallocation not matching the size originally passed to the allocation. Reported by: Aliaksei Kandratsenka PR: 279560 MFC after: 3 days (cherry picked from commit ead8e4c081e5c4de4d508fc353f381457b058ca6) --- contrib/llvm-project/libcxx/include/string | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/llvm-project/libcxx/include/string b/contrib/llvm-project/libcxx/include/string index ba169c3dbfc9..56e2ef09947f 100644 --- a/contrib/llvm-project/libcxx/include/string +++ b/contrib/llvm-project/libcxx/include/string @@ -1943,10 +1943,10 @@ private: if (__s < __min_cap) { return static_cast(__min_cap) - 1; } - size_type __guess = - __align_it < sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1 > (__s + 1) - 1; + const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : __endian_factor; + size_type __guess = __align_it<__boundary>(__s + 1) - 1; if (__guess == __min_cap) - ++__guess; + __guess += __endian_factor; return __guess; }