From nobody Mon Dec 15 22:49:38 2025 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 4dVZxz5LLkz6LSYM for ; Mon, 15 Dec 2025 22:49:43 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dVZxz4mr5z3y0x for ; Mon, 15 Dec 2025 22:49:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765838983; 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=VdO3htGy75+575/0hTAscu9TbS5pPWeTm4K6XJMU2d8=; b=etUkbhldUErDJLxw81Vm6Z0w0PCcKwzwPhkyRH5GOsS7DJBn0EUzqvRpINskQMu8HzbIjK wl/nGY+839XDonAFxabVJkn2qBX+b5wnFUT/aGB0kYO14MmcCbBugae3lTUcWvuZp1HEXA 9COVo+fhK0djxuHm5KSndhtVtOzyEFKuRtfH2I8L0EzqWLNSb+yetJPCVYBFa9THFXhTQZ v1MXBQ+KUBrP9fSSt6kB49nunlLSqrK63DWgoRjuUj4yulRlo9hN276+8dEQkn7NIUqQJ0 6uy/2w6baLRlkOptDhOTUtP/Byta4hBohjquhsm6gLSmXjb0gHb14Lmtlb/wbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765838983; 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=VdO3htGy75+575/0hTAscu9TbS5pPWeTm4K6XJMU2d8=; b=eaGUSn4F8VKXscsuoIt+VfAh+pw25bouj0rFfTVta/uaA+jiDXKcB1w96O4bTL2/5l/ZU5 ADyCBpnjedxkSkptcvsdf3MrGjBi3LzPnt+mJhLqQyBT0SSZ5wNynmqhlVsSj4VGbRh7aQ vLNuuMCqNmDAkLOBmv0Ye0ceQ935TF3cfo6UeTKxLzW0BsOfwnm0f0lziiGnX8KzqTZjQh HzzV5Jv53ZsmEEB3ZzkBMuGgXRTk5hNeR7WdEtYiGtncaKZUQ+vTsOfM2yd8UtSGyKni0P H9h9fph5UV75m5YwrugbXP3szqxoLxmBBvZt6NU/oZDpCCoVFQl9V0Kh2yiqMA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1765838983; a=rsa-sha256; cv=none; b=IiIq8zgFvi0XNdy78XcKK3z3yIHFi6s6xVLmm6fmVYZjAz+jWdV7HSmS9zygm8qFmT3xFK IDQwJuymF2utiEcI9m/UJudQcYyi6qN7zjwNppwW2mGbtK1eFulVCNxmiojGMch6xMTLGP rW3egFOSTMM0WdjXlHyO4tpiWzp/z6FLuOsWBiht3RdpW87/lwiBhQnI42GtS36puhtygZ AxtUgEu7OoIDkBh3RKaEm8OMkUcurRtnUyAawgpoO9oGY96LDsxTO/Y+HcM0rTGkXUsB8X Rpz15HohqCj5Eo85MSthARvUP/cnamnxE8qVu2qin4gl1mgHDTn/2377qI/sOw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dVZxz3hrszfxP for ; Mon, 15 Dec 2025 22:49:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 47078 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 15 Dec 2025 22:49:38 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Peek Subject: git: 2bf082df4931 - stable/14 - ctfmerge: fix segfault when building on macOS 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: mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 2bf082df4931fa0a2c557c428e7e7a333fd95ae5 Auto-Submitted: auto-generated Date: Mon, 15 Dec 2025 22:49:38 +0000 Message-Id: <69409082.47078.2b7e6386@gitrepo.freebsd.org> The branch stable/14 has been updated by mp: URL: https://cgit.FreeBSD.org/src/commit/?id=2bf082df4931fa0a2c557c428e7e7a333fd95ae5 commit 2bf082df4931fa0a2c557c428e7e7a333fd95ae5 Author: Mark Peek AuthorDate: 2025-12-01 20:50:24 +0000 Commit: Mark Peek CommitDate: 2025-12-15 22:49:04 +0000 ctfmerge: fix segfault when building on macOS The barrier code was using semaphores which have been deprecated in macOS and not working at all, causing a race condition. Since macOS does not have pthread_barrier_*(), this change uses a condition variable instead. PR: 290958 Reported by: wosch Reviewed by: imp, markj Differential Revision: https://reviews.freebsd.org/D54018 (cherry picked from commit 732b4aa05d78ca6831d02e67a43f34ad104f4f01) --- cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c | 26 +++--------------------- cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h | 9 ++------ 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c index c0719620dbde..e1f54e994ce3 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c @@ -38,9 +38,6 @@ */ #include -#ifdef illumos -#include -#endif #include #include "barrier.h" @@ -49,12 +46,7 @@ void barrier_init(barrier_t *bar, int nthreads) { pthread_mutex_init(&bar->bar_lock, NULL); -#ifdef illumos - sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL); -#else - sem_init(&bar->bar_sem, 0, 0); -#endif - + pthread_cond_init(&bar->bar_cv, NULL); bar->bar_numin = 0; bar->bar_nthr = nthreads; } @@ -65,26 +57,14 @@ barrier_wait(barrier_t *bar) pthread_mutex_lock(&bar->bar_lock); if (++bar->bar_numin < bar->bar_nthr) { + pthread_cond_wait(&bar->bar_cv, &bar->bar_lock); pthread_mutex_unlock(&bar->bar_lock); -#ifdef illumos - sema_wait(&bar->bar_sem); -#else - sem_wait(&bar->bar_sem); -#endif return (0); - } else { - int i; - /* reset for next use */ bar->bar_numin = 0; - for (i = 1; i < bar->bar_nthr; i++) -#ifdef illumos - sema_post(&bar->bar_sem); -#else - sem_post(&bar->bar_sem); -#endif + pthread_cond_broadcast(&bar->bar_cv); pthread_mutex_unlock(&bar->bar_lock); return (1); diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h index babf2e64e33f..138386f8ed46 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h @@ -33,12 +33,7 @@ * APIs for the barrier synchronization primitive. */ -#ifdef illumos -#include -#else -#include -typedef sem_t sema_t; -#endif +#include #ifdef __cplusplus extern "C" { @@ -48,7 +43,7 @@ typedef struct barrier { pthread_mutex_t bar_lock; /* protects bar_numin */ int bar_numin; /* current number of waiters */ - sema_t bar_sem; /* where everyone waits */ + pthread_cond_t bar_cv; /* where everyone waits */ int bar_nthr; /* # of waiters to trigger release */ } barrier_t;