From nobody Wed Jun 19 20:36:50 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 4W4Flk23s5z5NnbZ; Wed, 19 Jun 2024 20:36:50 +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 4W4Flk1Nq6z4NkM; Wed, 19 Jun 2024 20:36:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718829410; 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=FF4F4hFiY02f8iSo5MgNN7mvYv8nkVtvSMT//tDUdyw=; b=KUTP0snls8l6fs4lalru68SS+xhadz3YzSQlXgmH0lde5Xoae6zaBBDsexUridV4JnDQBp bFUYgOCNdzpjTLF+aNAnJwRq/bv4SaBRwkcxpXiQTQhwkl23EhOABJnZgTYmyko/3l/HKY HyU3I3rxEFUhdpiHq9O9s3Jln8b7x3qqxwnf7/gbsWQ0Rgk7D/u4YOxSrnWL/pL9CWGL3T xsoRPQ000KICyD232jmsdSIuqfXuPq1YwEPThPt4U/rDNmr8AxPx1tTCkc1LAwYcryOleP YX+2DjwTQKwJ2PoVsHy57ckKYQrLOu2QSqpr4BxXTCJq0iHYyCkmi2g7gJYnEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718829410; a=rsa-sha256; cv=none; b=ASRwzgT+f0coLPNTMnljKv4okYDavLnYGStAyGK9vuKNYv/iBDYayUsKyDSvg9iXXUXsYr 8AYv3hgC+SE8HO/2U1AcaFDmOV/wzKn4SDpD6zB1zgFT+618V3A/uypOWIh9SYz1P6npu6 Oc4wtR53iys54d4QMPkjGuu7evdRKgtr6pegxY0J6rDLnJGGwnjKnwHW6W1P+Ru+9DAbO9 fwZTVfeF11GubfszRfeBVFDGjGIlah6O+sVlZrRs4+DVSwoNzEmuJhaYn18gDyXB97HvJS WHskZ3UJaV8Wj8YVArXhEsZ3aQbMtRug+455TI2zLaqkErSAXfCFZjCsF7aSWg== 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=1718829410; 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=FF4F4hFiY02f8iSo5MgNN7mvYv8nkVtvSMT//tDUdyw=; b=kKtLS009Sorw2F2nZ4crFBNWLxDI8Uqe2VQZJLQwp7T+PXoyWx9V6WV0yghN4MMgeiRGIO 2mC2+XpmlHxoMZ1ozXWUGSdozm5yTCoaDdLaSW9klZF8OEl/bpkrkjZ24PJlMyLEh10kDX uG60PtlYVHJlvLMl02Rd5OI9GlYf1Kh6oGrZlL+8hDpzsEpIt25G8uaOiZ6oZtQgw49z67 cLH4gCh95oeWM4oZSkOOJGdV++uFNh5q0nFpxZCu10Akg98KLa2vnqE6aSSIewh+asrkgm PAy90qioDDfwB7vM0udUQKcaBR0TS1oOTBxmLSL6hsfZ6Z3l2sZr4+Oy9NV0Dw== 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 4W4Flk10YjzwNZ; Wed, 19 Jun 2024 20:36:50 +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 45JKaoLf001888; Wed, 19 Jun 2024 20:36:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45JKaoZP001880; Wed, 19 Jun 2024 20:36:50 GMT (envelope-from git) Date: Wed, 19 Jun 2024 20:36:50 GMT Message-Id: <202406192036.45JKaoZP001880@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 8e0e6b428cb8 - releng/14.1 - 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: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.1 X-Git-Reftype: branch X-Git-Commit: 8e0e6b428cb8ba01941e53256880f7993671e786 Auto-Submitted: auto-generated The branch releng/14.1 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=8e0e6b428cb8ba01941e53256880f7993671e786 commit 8e0e6b428cb8ba01941e53256880f7993671e786 Author: Dimitry Andric AuthorDate: 2024-06-07 18:42:53 +0000 Commit: Gordon Tetlow CommitDate: 2024-06-18 17:36:40 +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 Approved by: so Security: FreeBSD-EN-24:13.libc++ (cherry picked from commit ead8e4c081e5c4de4d508fc353f381457b058ca6) (cherry picked from commit 55c5dad2f305f74d1ff5ca85c453635511aab9b2) --- 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; }