From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16939 invoked from network); 21 Jul 2022 09:45:44 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Jul 2022 09:45:44 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1658396744; b=MywSYNSfYHq9wFWuAekTzG09xD20EKqnC/4K7kEfU0s2crT8jaC8bxgUvft/Nay1s/2SKgd5AT xdteWYrGbw1YAee8WA8OW0OqlczVa/wEg/anR+q4H1DHLpVse3fF29fM5m92TUQABTZpcM95Xr jaEwt4kQjUWZvoyuLQp+tGeD7Oy08fzfrgl+x88tFhWuny6pV0/+r1/+muFK6K5hg4AJIHefU6 GEaXV/dzlLc2xq9dAo0vrrC5jBsINMiGNQ84P7qq0ZsB6jgrmxV3E1qE7wFeDyhKchQw8XN0BH 0LhXmkX3BYTlU8MEGh1rWNRI9K4u3YA2kgoTF4inditmCQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (snd01006-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.22; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1658396744; bh=J6cUxhFMix2t0cKLFDD8QQR7cFNX6NZXdK1s5P+/1Hc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Message-ID:In-Reply-To:To:References:Date:Subject: MIME-Version:Content-Transfer-Encoding:Content-Type:From:DKIM-Signature; b=UAtp+Cy1Sq8p+Fthl34bispQ51tPsCd+4hQOa/xwry4tTz7AnUgy3pXSlV/Wvz6IQR8VLSk9Ct sxdW/6meq/2G01g8bY9YOMYtoNsFR8XGk22Xwr0sPPMpYTlYuhF8sykdQFJX7HgjNAJIZWWOYk UGgSTNOImQdIw7avcO0HcS7uQEXlO4XLGztjT+phlkebkTfvsf3Dw/k1w5jBheqxV62A4tQUNl 5Y5V8o7lIf1Bhd2P++FpGjC+s3cugy+EGmuZaKxcGN13vmy0rxTayUPfPzfe1dwskBZkcD7i/q NcpUjC2CLP/n1b6YRjMjx9WjCvUUbB4dDNYAAWSkBJgSDw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=jiovZrnWDTS3Xu9rBt9APUzSjt0LYo05gI/bH4fiIt0=; b=b5IBDgl7ITNsw94SqDLPmTe5j8 tBhiOyHW0Y/GBw9oa+i4+vcC+9SHskZ34NKAflObkTO/ARY4b9uof0TUuPuGqJNsLCQOWyLBpetex tppmSf3aa87lNROkv5e9SsELmjKR3/DfcBvEnPdyQjEJAjrt+uAzO+qNlZK2so3cgbml1zpb7f8Nw sGEP0+UkxiTNFF1lRxNOW+emln/1uzvKjralnr5cRIqc9D3f7UcsxP8jce5I+IRUdUu4J8cYDLNCy Djhpi2WzSVY6a5tqIWkojHy9MvBsGaFJ18XOP1OjjQudBh2YFW1NhvgbylzVhvQ41+ILMH1pCdKIa /IQPUF2A==; Received: from authenticated user by zero.zsh.org with local id 1oESkZ-0003FS-3S; Thu, 21 Jul 2022 09:45:43 +0000 Authentication-Results: zsh.org; iprev=pass (snd01006-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.22; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from snd01006-bg.im.kddi.ne.jp ([27.86.113.22]:16928 helo=dfmta1001.biglobe.ne.jp) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oESfO-0002lp-VK; Thu, 21 Jul 2022 09:40:24 +0000 Received: from mail.biglobe.ne.jp by omta1001.biglobe.ne.jp with ESMTP id <20220721094017680.CCQF.98282.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Thu, 21 Jul 2022 18:40:17 +0900 From: Jun T Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: Memory error on exporting XPC_SERVICE_NAME from a subshell Date: Thu, 21 Jul 2022 18:40:17 +0900 References: To: zsh-workers@zsh.org In-Reply-To: Message-Id: <5B18DF64-99E1-4110-90B4-AEA5D56D62EB@kba.biglobe.ne.jp> X-Mailer: Apple Mail (2.3445.104.21) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Seq: 50418 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: > 2022/07/20 9:11, Bart Schaefer wrote: >=20 > On Mon, Jul 18, 2022 at 11:46 AM Varun Gandhi wrote: >>=20 >> While bisecting my shell configuration for an unrelated issue, I ran = into what looks like a use-after-free on exporting XPC_SERVICE_NAME from = a subshell. >=20 > This is an error in a MacOS library routine. Previously seen in zsh > with constructs like > % XPC_SERVICE_NAME=3D0 somecommand The error occurs at line 5263 in params.c. I din't know why the problem occurs only with XPC_SERVER_NAME, but I think we can fix it (at least for relatively new macOS). On macOS, USE_SET_UNSET_ENV is not defined because setenv(3) had a strange feature that it removed a leading '=3D' from the value (Bart's patch in workers/38432); line 786 in zsh_system.h. But on my Macs setenv() behaves normally. I've looked into the source (setenv.c) and manpage (getenv.3) of older macOS (now on GitHub), and found that Apple has fixed this in macOS Sierra (10.12). El Capitan (10.11) is the last version with this problem, but Apple has stopped supporting El Capitan on Oct. 2018. There are very few Macs still running El Captain or older OS X now (about 2% of Macs?). So the simplest solution is to ignore El Capitan and older, and remove !defined(__APPLE__) from the line 786 in zsh_system.h. Or we can check the macOS version in configure.ac, as in the patch below (I don't know the way to get the macOS version from C preprocessor macro). Or we can use the Peter's patch in workers/38433=E2=81=A9 (with some = fixes?). diff --git a/Src/zsh_system.h b/Src/zsh_system.h index 6f4efce96..16f724401 100644 --- a/Src/zsh_system.h +++ b/Src/zsh_system.h @@ -783,7 +783,8 @@ extern char **environ; * We always need setenv and unsetenv in pairs, because * we don't know how to do memory management on the values set. */ -#if defined(HAVE_SETENV) && defined(HAVE_UNSETENV) && = !defined(__APPLE__) +#if defined(HAVE_SETENV) && defined(HAVE_UNSETENV) \ + && !defined(SETENV_MANGLES_EQUAL) # define USE_SET_UNSET_ENV #endif =20 diff --git a/configure.ac b/configure.ac index 77e381f50..890ef8dd2 100644 --- a/configure.ac +++ b/configure.ac @@ -1515,6 +1515,14 @@ else zsh_cv_use_xattr=3Dno fi]) =20 +dnl We don't want to use setenv(3) on El Capitan or older OS X because = it +dnl removes a leading '=3D' from the value of the environment variable +AH_TEMPLATE([SETENV_MANGLES_EQUAL], +[Define to 1 if setenv removes a leading =3D]) +case $host_os in + darwin1[0-5]*) AC_DEFINE(SETENV_MANGLES_EQUAL) ;; +esac + dnl ------------- dnl CHECK SIGNALS dnl -------------