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,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,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 122F921567 for ; Sun, 9 Jun 2024 02:23:54 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1717892634; b=ryrFmDMnhG2s0wv2lhXHOnULyu26Ff7oJ2n17221BXnWAHtGyQVFmiZKNBuJc3/gv8ZqZRXg7Z 40/aIjXAhNefvdwMMxtMduU0bcrq7JfkfwWUB4v/mJ4uJPA9pVRgjnVQDQHwdLblvbYaLX5Nx8 QyZ6VpluSIRT6S+Js4mMVVcop464I1otiBk+iKXlxqjRE6g/KJgBsOQMgID74qlCM1v3br5JnG qgPWeRg0efAXlxzlnAFHK0WqYQQ70SG7ZI/laLmRqFmeNwuR62VETyIWVKpVy8ktFr6OGXI4Xr H8xomaoQuoXzAsNHddozKo+PfflliRMxAMhX5gpd82/jYg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f170.google.com) smtp.remote-ip=209.85.208.170; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1717892634; bh=ZnuaneqIN5xw0zn7NaF7CtjOi5eVQI8YYRhdonQgxBc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=AkkRe636YUrY4m0jJpegAYK7ryEV8VxEfn1F+ScHgFQBvu1IfNbBEg+YgZ/ulCYhFAjG2EUSlT +jWcNJpy/liijBA07qlxLXPmo/E+4PrueFBSlol/hg0xyYz5TpyQkHqk0XYoWqRr+77kkQ08bJ wb6fSRZwVaJoEG3f5ZFBhrC4ZM6snUqu2NM4aLgQ2aKBF2VsYyWyaM3KuAYd0kpYDLc3t0RrX2 S9Cbxh3MtMk9ju2uQPjVDbf7LH9Z237TkHbi32mb3sQ1WpKy/ELHp9mDaZi+AcCuSS2KCNKyYe DhgNhQdGXNeb0YTv68ag9RSKfCtKfBWzacKkIg0EtuaMpw==; 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:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=GuvTHEdbYxJgTk3XdgXKCbDN9pSCqs1bqutPW682OQc=; b=QV4JrwupVnk/G+Oo5z4WtJD+7i 6qV/qmFuhybeooezfu3wRpKfMPoCDNUznKJVGGdSBCQVdLUgVcT3ah01DkZ2KZYSt++bCZvRToMkV NWxSDC57aKkQNyn8wsyxAfSInmlgJsUaDk3zhcMtUsNT+PHSqYH7mpvHU/qEeXtPGIwwnE0VTouS9 DqXXJHcCphxMPayg1qPdrIhpDWqp4+oU8QroacLY3IFCm8ESiZfKJyLGYfDLjINXsnZEQgHhBm/H2 xqDwbs69Jb/CPHxRJB8iL74rwQLOgR7IJanXpKFQa+OMEWJujJPxGo29R8DAOX6/U95j4CSglhCdp ons0SglA==; Received: by zero.zsh.org with local id 1sG6Lh-0003WU-7z; Sun, 09 Jun 2024 00:23:53 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f170.google.com) smtp.remote-ip=209.85.208.170; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f170.google.com ([209.85.208.170]:60695) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1sG6L5-0003DO-VF; Sun, 09 Jun 2024 00:23:17 +0000 Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2ebdfe26226so1969631fa.1 for ; Sat, 08 Jun 2024 17:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717892594; x=1718497394; darn=zsh.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=GuvTHEdbYxJgTk3XdgXKCbDN9pSCqs1bqutPW682OQc=; b=IelEUuBGK1AYajEnnmkCcLD/+PY3QtY7fDWma2RoWH5JYRegck1qPAIEQ/b8HxYVmb WYxwDSF1xvfVvX65VMRlpxs0y8UkvogN4T+MCA0MlqmC6B2p53CDtrF4kA9Sd+vixxVw Sl5KNvotPJhZJ2FnpHwu2CL+mNGhkZJOQbzqhJE3YK/ZCjTJxausvbEnD0zQymDVbyAG iwWjmpbLUa+rbWhekcoCUgyUXJtVoRNQ5Omx3+0CJtXHSsdFLnManxPtlOyizveyf6W2 5qjKQ2DQ2lQOI5blg+yEc03W4CXdTu+oW7TfBmEfNPsF3YgL/FTiViBjOP/WP/SILOeG 2tSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717892594; x=1718497394; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GuvTHEdbYxJgTk3XdgXKCbDN9pSCqs1bqutPW682OQc=; b=QVQaI4skFGnHwnVCjfpOVY8omBLPinpCUjp6O4rJtioa2PQ09KWMO9urluf3XUtXY1 XdhTxUJGvtIxa9aTGnPmKmRaaIIrzhD9M1yt6KM1ltkppPtY+DxtQfpeuIFI9gYOk+Ht 9nJrryS2TybvQpxdqTk0zZfbBCEUnxrT0B9v2RfRVJ0u7BdnbBd4nzbQFmboPplcY+g0 t/Rd1KeQzrtuoBhbtZj9Lx6VRM5fT54ufV8C8xfIWGPi4OFdfbLT/yl+BnB8R7o2yn4/ UGelXFyIhcbYDrOA0uOIXLldVDKP+9fsHLwYLGZObXeQ+MsaF2OKkpmUyiXa73NcL3n9 4mQg== X-Gm-Message-State: AOJu0YynnZvqjMVfDsql8OL/T2AHoVDY4X/zHRAwkV5LoWal1KgJ4G1b 3PpvGazkwhkva2MKxNc5Ck0NZC6g6I4riUuuZdZKBAsCUWmIP0xlVI8xkJ7502VZyUq0NdPmcUO i6np7MQGRP4MeUQi5HLFWRPGB/FhPnA== X-Google-Smtp-Source: AGHT+IEXyzcFL3nsg4MGWTucjCjAJf40Zz7fArtary3lEnqBilueu6Kr3vRH1unht1OL0D7V4c7E4WAeLDdeoJQUNvA= X-Received: by 2002:a2e:914c:0:b0:2ea:e70b:ae3f with SMTP id 38308e7fff4ca-2eae70bb0f7mr28769821fa.29.1717892593966; Sat, 08 Jun 2024 17:23:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Mark J. Reed" Date: Sat, 8 Jun 2024 20:23:01 -0400 Message-ID: Subject: Re: [BUG] Misplaced quote in %d printf format crashes Zsh To: Zsh hackers list Content-Type: multipart/alternative; boundary="000000000000d36722061a6a091c" X-Seq: 52950 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: --000000000000d36722061a6a091c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Duplicated on my Macs; /bin/zsh (5.9) exhibits the crash on both x86_64 and ARM (M2). 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. On Sat, Jun 8, 2024 at 7:04=E2=80=AFPM Mark J. Reed w= rote: > I'm away from my Mac at the moment, but FWIW, the crash does not appear t= o > happen on Windows (MSYS64): > > *(0)> printf -v result " %5'd"* > *printf: %5': invalid directive* > *(1)> $0 --version* > *zsh 5.9 (x86_64-pc-msys)* > > > On Sat, Jun 8, 2024 at 5:13=E2=80=AFPM Philippe Altherr < > philippe.altherr@gmail.com> wrote: > >> On macOS 14.5 running Zsh 5.9, the following command crashes Zsh: >> >> % zsh -c "printf -v result \" %5'd\"" >> >> zsh:printf:1: %5': invalid directive >> >> zsh(41890,0x7ff8450ddfc0) malloc: *** error for object 0x600002c811e0: >> pointer being realloc'd was not allocated >> >> zsh(41890,0x7ff8450ddfc0) malloc: *** set a breakpoint in >> malloc_error_break to debug >> >> zsh: abort zsh -c "printf -v result \" %5'd\"" >> >> Surprisingly, dropping the -v option, removing the space before the %, >> or adding an echo command after the printf command avoid the crash: >> >> % zsh -c "printf \" %5'd\"" >> >> zsh:printf:1: %5': invalid directive >> >> *%* >> >> % zsh -c "printf -v result \"%5'd\"" >> >> zsh:printf:1: %5': invalid directive >> >> % zsh -c "printf -v result \" %5'd\"; echo foo" >> >> zsh:printf:1: %5': invalid directive >> >> foo >> >> Philippe >> >> > > -- > Mark J. Reed > --=20 Mark J. Reed --000000000000d36722061a6a091c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Duplicated on my Macs; /bin/zsh (5.9) exhibits the crash o= n both x86_64 and ARM (M2).=C2=A0

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... an= d it also did not crash. So it seems to be something about Apple's buil= d environment.

On Sat, Jun 8, 2024 at 7:04=E2=80=AFPM Mark J. Reed <= ;markjreed@gmail.com> wrote:<= br>
I'm away from my Mac at the moment, but FWIW, the crash does not appea= r to happen on Windows (MSYS64):

= (0)> printf -v result " %5'd"
printf: %5': invalid directive
(1)> $0 --version
= zsh 5.9 (x86_64-pc-msys)

On Sat, Jun 8, 2024 at 5:13=E2=80=AFPM Philippe Altherr <philippe.altherr@gmail= .com> wrote:
On macOS=C2=A014.5 running Zsh 5.9, the following comm= and crashes Zsh:

% zsh -c "printf -v result \" %5'd\""

zsh:printf:1: %5': invalid directive

zsh(41890,0x7ff8450ddfc0) malloc: *** error for object 0x600002c81= 1e0: pointer being realloc'd was not allocated

zsh(41890,0x7ff8450ddfc0) malloc: *** set a breakpoint in malloc_e= rror_break to debug

zsh: abort=C2=A0 =C2=A0 =C2=A0 zsh -c "printf -v= result \" %5'd\""


Surprisingly= , dropping the=C2=A0-v=C2=A0option= , removing the space before the=C2=A0%, or adding an=C2=A0echo=C2=A0= command after the=C2=A0printf=C2= =A0command avoid the crash:

% zsh -c "printf \" %5'd\""=C2=A0

zsh:printf:1: %5': invalid directive

=C2=A0%<= /b>

% zsh -c "printf -v result \"%5'd\&quo= t;"

zsh:printf:1: %5': invalid directive

% zsh -c "printf -v result \" %5'd\"; echo foo&= quot;

zsh:printf:1: %5': invalid directive

foo


Philippe



--
Ma= rk J. Reed <mar= kjreed@gmail.com>


--
Ma= rk J. Reed <mar= kjreed@gmail.com>
--000000000000d36722061a6a091c--