From nobody Sun Feb 1 14:34:29 2026 X-Original-To: dev-commits-src-branches@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 4f3shP6jDBz6QRgC for ; Sun, 01 Feb 2026 14:34:29 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f3shP4Dypz3SK6 for ; Sun, 01 Feb 2026 14:34:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769956469; 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=LjqaZ/M9MOZPnc11NkbxlRZPlj9p0JOQVAwbqbLkqp4=; b=ExWWLn59qK2Eb/7r9lHZbxb0GiiVApaGXJ5mayS4p9iSGhSu+HKRDeRlVlAsHRFa31Eyqg BJPgeFZ+eFzochdBiVJmp4jp08a1vzkCfDVCeNXKyK8BvWPnENWVCjpV6etoT7cX5gYJrU B4OtNN/22TY5H4oIAAhK8B2N5lTy5yzaz9Gqdqe9ywpukHvqtwOrbXbCHL+I8Jw53Mft6p WCfe/J0kmOP2R2RDWjBfzFdPOOJqpKRCl5RB1AHNag5IoGMfccDK3EEwIivV31lo4XNUfs bVD/Aw7LTyZzCQ29iTJt7pH3gU+5jbUMVlZ8OvJRC8zG+izVp7K76u6x8CCyVw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1769956469; a=rsa-sha256; cv=none; b=Eyeq+h1iUhlhMgBEv4Hc21pR8v8ocYlIQmYt81FVtB5e5Pei7tkuVZ9Q3RzPu2sFydqo19 2u2FOZFUuTk1mx0dwGg7rGpdPUr08cfl7z09QX0pyc5FFVJ1VrKns1W/yFZLTH63vyZoGV feec3s0q555JCKV7F62pamt6mojOvRo1eTUfTnn5Sn7do/9rY5AhVUg+uUs2NAHIGuuiWg 75WuYmCEnoCNEjxsbzP9hKGYhpd+Au1i6hz7Bx0y1Abi0biFSQBDdQnRzvd06IwvrBuadf v/sBuy4NGN9VYtCQNYz92QaVz+jXzQAMryURYiNKqcncO8wMvAanUwIvF6qd9A== 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=1769956469; 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=LjqaZ/M9MOZPnc11NkbxlRZPlj9p0JOQVAwbqbLkqp4=; b=EsowQt0oeCz6xkzz0+xwqOYrsP3EfAKtpmegcaCMPMJ4O6wrVT4mcQlOPVMkhVt9xTmrQ2 wvGU4EFWx2Obz7O+Jds9qje9P49Nu10KAjECgKRhPBkjedfroQOYGjWH1LPOkCGH7yT0yq kw/xWEUCYt/ZzvnRTUvVCiJZBeioy7QkvUK6EsJNpia7SMflaJwFTl9M3YakHjj8k9MrSG +qHhq9Z4nZL+TlIy86ZF9lS+6Bu5uLPworyCmmrzjYkokYVhLalYXzVb7CSKuHav+5gjUt 4k8ZQuuKaJTXyNE/5e5dGoHHRcVCYt21exudjyExJevVofYI6OOpF0YJ+/Vwtg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f3shP3mB6zl25 for ; Sun, 01 Feb 2026 14:34:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 38034 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 01 Feb 2026 14:34:29 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jilles Tjoelker Subject: git: 21d665d7dd9e - stable/14 - sh: Fix job pointer invalidation with trapsasync List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jilles X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 21d665d7dd9e50e3975b117a4f3c0f50ed7bd642 Auto-Submitted: auto-generated Date: Sun, 01 Feb 2026 14:34:29 +0000 Message-Id: <697f6475.38034.6be56678@gitrepo.freebsd.org> The branch stable/14 has been updated by jilles: URL: https://cgit.FreeBSD.org/src/commit/?id=21d665d7dd9e50e3975b117a4f3c0f50ed7bd642 commit 21d665d7dd9e50e3975b117a4f3c0f50ed7bd642 Author: Jilles Tjoelker AuthorDate: 2025-11-17 17:42:01 +0000 Commit: Jilles Tjoelker CommitDate: 2026-02-01 14:33:50 +0000 sh: Fix job pointer invalidation with trapsasync Calling dotrap() can do almost anything, including reallocating the jobtab array. Convert the job pointer to an index before calling dotrap() and then restore a proper job pointer afterwards. PR: 290330 Reported by: bdrewery Reviewed by: bdrewery Differential Revision: https://reviews.freebsd.org/D53793 (cherry picked from commit f44ac8cc9c10d7305223a10b8dbd8e234388cc73) --- bin/sh/jobs.c | 6 +++++- bin/sh/tests/execution/Makefile | 1 + bin/sh/tests/execution/bg14.0 | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 3c34897a803c..70928c8ca1ba 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -1084,6 +1084,7 @@ waitforjob(struct job *jp, int *signaled) #if JOBS int propagate_int = jp->jobctl && jp->foreground; #endif + int jobindex; int status; int st; @@ -1091,8 +1092,11 @@ waitforjob(struct job *jp, int *signaled) TRACE(("waitforjob(%%%td) called\n", jp - jobtab + 1)); while (jp->state == 0) if (dowait(DOWAIT_BLOCK | (Tflag ? DOWAIT_SIG | - DOWAIT_SIG_TRAP : 0), jp) == -1) + DOWAIT_SIG_TRAP : 0), jp) == -1) { + jobindex = jp - jobtab; dotrap(); + jp = jobtab + jobindex; + } #if JOBS if (jp->jobctl) { if (ttyfd >= 0 && tcsetpgrp(ttyfd, rootpid) < 0) diff --git a/bin/sh/tests/execution/Makefile b/bin/sh/tests/execution/Makefile index 2b4f88db989c..e201cfdecf87 100644 --- a/bin/sh/tests/execution/Makefile +++ b/bin/sh/tests/execution/Makefile @@ -19,6 +19,7 @@ ${PACKAGE}FILES+= bg10.0 bg10.0.stdout ${PACKAGE}FILES+= bg11.0 ${PACKAGE}FILES+= bg12.0 ${PACKAGE}FILES+= bg13.0 +${PACKAGE}FILES+= bg14.0 ${PACKAGE}FILES+= env1.0 ${PACKAGE}FILES+= fork1.0 ${PACKAGE}FILES+= fork2.0 diff --git a/bin/sh/tests/execution/bg14.0 b/bin/sh/tests/execution/bg14.0 new file mode 100644 index 000000000000..e27f77e9b7b3 --- /dev/null +++ b/bin/sh/tests/execution/bg14.0 @@ -0,0 +1,9 @@ +T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXXXX` +trap 'rm -rf "$T"' 0 +cd "$T" || exit 3 +mkfifo fifo1 || exit 3 +set -T +trap "for i in 1 2 3 4; do sleep 1 & done" USR1 +sleep 1 & +{ kill -USR1 "$$"; echo .; } >fifo1 & +(read dummy