From nobody Sun Mar 20 21:35:59 2022 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 F128A1A164E7; Sun, 20 Mar 2022 21:35:59 +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 4KM9zM6B40z3q2m; Sun, 20 Mar 2022 21:35:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647812159; 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=csPvg8Vfybi3bXxP70W0tAdRPHDB1dxqiVWCYogjBrE=; b=o7zdxe/dOgk7/vhRYSlgegHWm2KPD3DGV9rLGHYuoHRf2oY1S7rsPly/RpO+3Fj2IDvIL0 cYbZftGFZSOCIZn9N81IL/LHGO7SP4oAhjCbI3F3jcGDIvjSZnFc0f8HSuchabR4c6Hu7X oCfIFCAHgqjGUDcWZRD/EerxIXnlk+VjBGRwX8bD1TfpouC1siRTCtTXWCrSrw03npMWRT K94dof9XPJuGaHDVuT/2bNHJrUa4Cm0s5mrRngJC+Jd6C0i3HlUM54gG0RLRHL15Rl+Bnp DNaVDOoUfMZyFx/UzutQv7UI1SoTDoIsV9fTVXUptHVH/wiWPoczUR07m5Fkug== 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 957B17121; Sun, 20 Mar 2022 21:35:59 +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 22KLZxmi038507; Sun, 20 Mar 2022 21:35:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22KLZx8r038506; Sun, 20 Mar 2022 21:35:59 GMT (envelope-from git) Date: Sun, 20 Mar 2022 21:35:59 GMT Message-Id: <202203202135.22KLZx8r038506@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 7819a911ff51 - main - Merge libcxxrt commit f2e55091e2e878386c9f7974d4922bbdc4faed84 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/main X-Git-Reftype: branch X-Git-Commit: 7819a911ff5132b34996c8b09b2a024cd10fd4fb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647812159; 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=csPvg8Vfybi3bXxP70W0tAdRPHDB1dxqiVWCYogjBrE=; b=eujE4qiOsbSX+6ISkZUoHpu1zFDVy2wVEBHyF+3ctE9hpZfpIaBeB18Hz8bF9jIC/7eG/h uyLnNXKzLUt25nWB/bIDguxBAE76L4O4ieU4pptL9e5FlevbewYfObGf09FFLtgMV8JtZT VoBFwTZiKMkY+Hze3q5ZVyUaNzb0SGZnprCAT3vtJ8j/v1z27D+zuNX74wUQKAYiwb+7AU 0gXyw4LMVZX6TCtcWSRlnZVg2VZI6ZmPVVkq0zYmxSek9bB2eK/faOgoqq7kclZvDcvmU5 LbDo/wuIrpUJJZMegtLtiQ9PyJy91QfHqEyYN+iYX/RS+uDbkhrCBpisNXgJyA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647812159; a=rsa-sha256; cv=none; b=f19PC5HR1MD8bUEz8c3av9eJCbR2rap/1ek3krG1I+gAyxLQIuI0FaWinIjPPOts3/GVRH 6/qKXtLHiqGdqfxP82kC245JGTpp0OMc+daLYQqCFiyW4Wwd0m3ZnMMH0Z8LasZqN5VVBZ Lug5QQk2zzP+ILMHT3jldqOn65si1K77X0agwo7POvIyu1poCCV0tD2KnWuLKB+8z6gg90 ocPDePSvF/q0icD1/lU0168OZQgd8qA2dz6fS7TnPX45EwgAh1C30yt8qBpNclilCVmRd8 c1Hv7BXURDHFFzRxzLJhozBKwezE64qW0e5Ff4KhONSkJiySJBud7T2QzU+05g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=7819a911ff5132b34996c8b09b2a024cd10fd4fb commit 7819a911ff5132b34996c8b09b2a024cd10fd4fb Author: Dimitry Andric AuthorDate: 2022-03-20 21:21:28 +0000 Commit: Dimitry Andric CommitDate: 2022-03-20 21:34:41 +0000 Merge libcxxrt commit f2e55091e2e878386c9f7974d4922bbdc4faed84 Fix unlock in two-word version and add missing comment. Fixes #15 Fixes #16 This should fix the hangs in __cxa_guard_acquire() reported on i386 (and possibly other 32-bit platforms). Obtained from: https://github.com/libcxxrt/libcxxrt/commit/f2e5509 Fixes: 56aaed388b0a MFC after: 2 weeks --- contrib/libcxxrt/guard.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/libcxxrt/guard.cc b/contrib/libcxxrt/guard.cc index 515992563a10..cb58aa7da28e 100644 --- a/contrib/libcxxrt/guard.cc +++ b/contrib/libcxxrt/guard.cc @@ -69,7 +69,12 @@ * progress). The bit to use depends on the byte order of the target. * * On many 32-bit platforms, 64-bit atomics are unavailable (or slow) and so we - * treat the two halves of the 64-bit word as independent values and + * treat the two halves of the 64-bit word as independent values and establish + * an ordering on them such that the guard word is never modified unless the + * lock word is in the locked state. This means that we can do double-checked + * locking by loading the guard word and, if it is not initialised, trying to + * transition the lock word from the unlocked to locked state, and then + * manipulate the guard word. */ namespace { @@ -227,7 +232,7 @@ namespace // If another thread did manage to initialise this, release // the lock and notify the caller that initialisation is // done. - lock_word.store(initialised, memory_order::release); + lock_word.store(0, memory_order::release); return GuardState::InitDone; } return GuardState::InitLockSucceeded;