From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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, DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 3F2AB25750 for ; Tue, 11 Jun 2024 04:24:46 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1718072686; b=rl3RCabdDpEJv8SR7u97TfoxjN0qSWaXAHZLx567v3YpeyQ0F7CFtLa9YYaMqs1gcMSaICuQ9V cN7ctQpIygXIN3HSttkmRlg8AWNzQajTEpDH8k6IsSce1LiPYieLEM3zYSMFHMQgXgmP6L8Xhi 3KatZkC69QcnQn7ECBcUny7rT585/4CmEAgXFnVUhhDSD3rdN6pi+K1ERv+MfUEJ7OPVIY3K7g WIU3RPsoMLia8ZxM+5eyqKnBgpHl43/72o8ld4aHXFKxpRdIflOtw+P2cJ5XU5WPxWB3W8jIU9 x/N9qoLWZ4blVzxSbCvRbMFO6S04o0Iyr5k0vZIVhgyUxw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta-snd-w08.biglobe.ne.jp) smtp.remote-ip=27.86.113.24; dkim=pass header.d=kba.biglobe.ne.jp header.s=default-1th84yt82rvi header.a=rsa-sha256; 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=1718072686; bh=9JJPk7Byegp5N93u575cDJk1C3n8QdDbQ28pLXyDTkA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:DKIM-Signature:Message-ID:In-Reply-To:To:References:Date: Subject:MIME-Version:Content-Transfer-Encoding:Content-Type:From: DKIM-Signature; b=JUeR9hodfnw8Po4Dut0HQao/iD1fvP7EsLwH31+lA/HnEVKL97HdEIPSuGwGDHfYTZgzSdxJim BOMgIrEfV4TZZeVixmFhk70NechC7+x1Ml6KiXntERArT3rePlIrxpgGuEiI7SRlKw5dEZahN1 RzE9rsUDsbt4Rf/33MVbOT1RP1wVaIV3xGLZl75DtscS44lb/c6nuViY5pnusdC7TfxMK9NE7J vfjL4gkWTgSnNDdZgpIr8QJPnr6DiADk+f5DZ3r0uiAjhCy47HQZL334c5Vbsb/pb5Ss35+wBp un4si3u3yjmNHbi3KEG/oCp9+ph3fhQIMeSs3cWTRxjQrA==; 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=eapkp1yu97tF2EnmyalqR77wGT5CubvnGif8AwdK/74=; b=MON1/7sJJrqAA94lkpkqoH1MZV r7mXmAq7jg+ex2nBjbkRf13FAuv8nUomkaK51U6LzBLgTOlYLNTVS9rgxkO2V6vOLvFqssnNKjeC9 kaZ87ZqDUr7oP8AePHV/synSZgGR6Are6Xl4WSiWS1OS2HU8pBEd1uFD/wcnOnExq6+pbq36MBCVN /ZuT/DIdAsLhKodeOe35jlg+xjJao2JQgu2R7kYM8CdjqnnbWMbG7LTdZ/QJays7ZbJxavobkWgOw XOW+lWV8ptfDbQWjKWbck8SVdORXZ5/C32kHagEnTI7OTT2GIprUWfvdmwKsQAdsIu2loDOmlqmj4 cF7mLWDA==; Received: by zero.zsh.org with local id 1sGrBl-0003bE-VB; Tue, 11 Jun 2024 02:24:46 +0000 Authentication-Results: zsh.org; iprev=pass (mta-snd-w08.biglobe.ne.jp) smtp.remote-ip=27.86.113.24; dkim=pass header.d=kba.biglobe.ne.jp header.s=default-1th84yt82rvi header.a=rsa-sha256; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from mta-snd-w08.biglobe.ne.jp ([27.86.113.24]:3168) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1sGrBR-0003Im-NL; Tue, 11 Jun 2024 02:24:29 +0000 Received: from mail.biglobe.ne.jp by mta-snd-w08.biglobe.ne.jp with ESMTP id <20240611022419433.MICJ.33920.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Tue, 11 Jun 2024 11:24:19 +0900 From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: [BUG] Misplaced quote in %d printf format crashes Zsh Date: Tue, 11 Jun 2024 11:24:08 +0900 References: To: zsh-workers@zsh.org In-Reply-To: Message-Id: <4C5DD888-4539-4910-B633-A7A299AD3320@kba.biglobe.ne.jp> X-Mailer: Apple Mail (2.3731.700.6) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kba.biglobe.ne.jp; s=default-1th84yt82rvi; t=1718072659; bh=eapkp1yu97tF2EnmyalqR77wGT5CubvnGif8AwdK/74=; h=From:Subject:Date:References:To:In-Reply-To; b=cFcUkwYWEePXe+CAnfb40q0u3+W4J2U7nJttg0qYG2Eln8A7hHaqgJGrbUBHG5YcnH0ombc4 97YIQq1hbs5V9q3N9scuAx2oAOt9aD8ecSM3mpz8T9Ry/IPDrOYVdO8jBmFQ0CCUKsTBkCkNMS K4AVIOwNZyPEeeCouFosDhMzoRcmYxVhjA93z3+bB0zepkE9U9e2xmTqAgW2Iqu4eFCsuf4LO4 UKqyNTsy3wsgJObPT+8sleGLSklC23HnxJWHxfkJ280rX3N0gqS4+qK8Mbrd3QAEk+Sy5r3ihM lPiGHM72eC26qhHN0RpoysNnkoBi64LhSZyHQbK8cvJleVoQ== X-Seq: 52951 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: > 2024/06/09 9:23, Mark J. Reed wrote: >=20 > Duplicated on my Macs; /bin/zsh (5.9) exhibits the crash on both = x86_64 and ARM (M2).=20 >=20 > My locally-built 5.9.0.1-dev does not exhibit the symptom. To see if = it was a build thing or the result of a code change, I checked out the = zsh-5.9 tag and built that... and it also did not crash. So it seems to = be something about Apple's build environment. Which version of macOS are you using? I tested on Ventura (13.6.3) and got the same crash with my local build of both zsh-5.9 and the current git HEAD. Valgrind (on Linux) tells me that the memory allocated at line 4877 in builtin.c is lost: ASSIGN_MSTREAM(buf,fout); free(buf) _is_ called at line 5863, but it seems we need fclose(fout) before freeing the memory. But the macro CLOSE_CLEANLY(fout) does not = close fout since CLOSE_FOUT() does nothing if HAVE_OPEN_MEMSTREAM is defined. As the comment /* Why do we care about a clean close here? */ suggests, I guess we can simply close fout if it is not stdout, just like lines 5228, 5265, 5299. diff --git a/Src/builtin.c b/Src/builtin.c index 7bfb1ce1d..cd0ee7522 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5455,9 +5455,8 @@ bin_print(char *name, char **args, Options ops, = int func) } zwarnnam(name, "%s: invalid directive", start); if (*c) c[1] =3D save; - /* Why do we care about a clean close here? */ - if (!CLOSE_CLEANLY(fout)) - zwarnnam(name, "write error: %e", errno); + if (fout !=3D stdout) + fclose(fout); #ifdef HAVE_OPEN_MEMSTREAM if (buf) free(buf); -- Jun=