From nobody Thu Jun 08 21:03:30 2023 X-Original-To: dev-commits-src-main@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 4QccBW04BQz4bVlH; Thu, 8 Jun 2023 21:03:31 +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 4QccBV6fKMz4MDB; Thu, 8 Jun 2023 21:03:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686258210; 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=Y6Zi9Eonqs3ZEBQ0QFIsRLS2pCy5IyNhjTIkGdZEKoU=; b=CV6o9QE2nAA79pEhzywtExLXj/H84GaI2961Rm0Ker/OSTSCgje5p+tLNMc3LWOHhvF8vp LiZzoGNVWSflYhchS0nakC/iUNs30fOPV4SPMp/jF3Ag93PMsolnIwKKKP4538xIPgWNBx 1IW/4UiV065VGZTgXtx+RdJ4QlMgj18gC2qRRKK0heHCTeJbebm511Q4TetS79sbyeR1mR xJNpCHQ0ZfU9zzwTKeKyZT4Ef2+r3c2udCEm1zTZp14r6jeTDYGBLQ5/5DstpeEch9DbuR bM8A+acTG5XQT6T5+bUYLczlFKa6iEuKIWCzVFZoyrEAstkyl4SV01EJf5Yclg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686258210; 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=Y6Zi9Eonqs3ZEBQ0QFIsRLS2pCy5IyNhjTIkGdZEKoU=; b=oS+BCDtpTlFyGstPuEIQFoILM8eInW36cTa/BCRdn0WuWb+9zsTcDKJqQIvoUnn3CyCwzM 4twrxboYn3uQHVpu5I2WvJSWmMU8gzQjcPBMIowK+e/wrCjG+gG8CUbl+Q0cdZBIKOixSH I2yy9jDOTbARibUDghmyOv83Mjr8WuYITNVHoRL2MGZBh2zn4IcGOg2X7wsQcKVa6i04b7 OMCVmWtAYUGTtdrnBe5z5U/5C12Y64DL1Xl1DXczwl704/VNm2oCU5YhTwK0oH1iV4czj9 uOCSK1nNF/MjPcSgvH1nRsgBwr1LBwD3emsw+PH0oiXjls28ofhPzmkYRgVSWQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686258210; a=rsa-sha256; cv=none; b=iAlaSaVtCivg+clvsJjq+PilbYzG6wsqtJcjYT5c6bHoz45dwCi6L1np0zFVTKlWJojOqw 13hDiFYYz5mVv1nxL8+5goJIoxWBDznWx8ghNigbJRIhB7Ba8jPDR1ShR9IbDcaWaIVuZR wtCBJORAxhkLZuc0H0i2Okn4n2jfabneJLIxRbcilOZxkC+82AQ/u4mk2Y6g8DX/bQL0Uv 27OIAGSG/pSWrZdw4ZahOehLZzgJMEb6Z0bQZu+ZdiQ1h+IG3C+Xt7cBPHZjVDJnSbgQhB tGkidZ/usetkPLh5IsS1SbjEK/+ru1PW2Eb+HtZMjDuKiIkWCDiZLlNth8YQLg== 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 4QccBV5jwnz18LP; Thu, 8 Jun 2023 21:03:30 +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 358L3UMR012588; Thu, 8 Jun 2023 21:03:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 358L3UDD012587; Thu, 8 Jun 2023 21:03:30 GMT (envelope-from git) Date: Thu, 8 Jun 2023 21:03:30 GMT Message-Id: <202306082103.358L3UDD012587@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jilles Tjoelker Subject: git: 2178e8c27aad - main - sh: make smark a static variable instead of a local in main() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 2178e8c27aada86ce679d90b8d6cd61dc3bc7f6b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jilles: URL: https://cgit.FreeBSD.org/src/commit/?id=2178e8c27aada86ce679d90b8d6cd61dc3bc7f6b commit 2178e8c27aada86ce679d90b8d6cd61dc3bc7f6b Author: Daniel Kolesa AuthorDate: 2023-06-07 15:06:00 +0000 Commit: Jilles Tjoelker CommitDate: 2023-06-08 21:01:43 +0000 sh: make smark a static variable instead of a local in main() We are modifying it after setjmp and then accessing it after the jump, so it cannot be a local. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D40415 --- bin/sh/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/sh/main.c b/bin/sh/main.c index a77f9528064d..3dd2b0d83738 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -100,7 +100,13 @@ static char *find_dot_file(char *); int main(int argc, char *argv[]) { - struct stackmark smark = {0}, smark2; + /* + * As smark is accessed after a longjmp, it cannot be a local in main(). + * The C standard specifies that the values of non-volatile local + * variables are unspecified after a jump if modified between the + * setjmp and longjmp. + */ + static struct stackmark smark, smark2; volatile int state; char *shinit;