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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24115 invoked from network); 19 Jul 2023 22:24:29 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 19 Jul 2023 22:24:29 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1689805469; b=sVYcqVEfHbaiBWcsrLa0WLSyYtL2gNBM2JXcpBqON0WWuUYDwRUspieEX4tmOw01g9ad8Z+xgs 3D3tPySqev+oXvggO5jbSuc/CFatTWDLoGUiDS4BGqjLzQMAYUmfFTdW0ZbxgrjWltXzk+FlEZ mtkNCe2PdgyPq+XCR39d0g9Yy5uOCuela3cs9sbQ/7xRttpbma6G2xZDbkCjEQ1Tpx7zICWDAz jpsJmlR8EYrLACrib+wTeIIHV0HkmjIIaDO/UajKlbtDEY/wDOjBl0Sk9MEBqv3Uly54OZByxu M4m8nqIDehHRSsjnZMOfPDGN9itDHm3yIGN7JUeuh4ruqA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-qt1-f175.google.com) smtp.remote-ip=209.85.160.175; dkim=pass header.d=gmail.com header.s=20221208 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=1689805469; bh=qg/Y8qYwZrvgYsy+vPedrmO6BY7wReWx5U0XGf5wm08=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=TMswVS0QTakWINTEApzYMx3yW06zJg/y0oHuFDwHKs/ZgC97O2NPDixhEuLhXC34Fcz9q2oKuV hOTNVyq4jYq8DNgA7ZdX/Y3LAQDHDu9w/DPPFsQEwr8fRsR/7S4KSL1kBbzB6AwM5VpNYg9wQx 7lua0x1msN/6u2vR+7AOn0hZC1Nzg/SRNhR1J+3Uv4pQ+uBpjT7oUfOD3kv1rP4BPuWIMYmIw1 n3Rz/Y7WNstFgJDPjzoMl6qleJJrbn17wW1m40exPe5acVGopyZbgrczWpum2Orlj174s4s30O EI9ek7GgZFX67PVL1vlOoOZaLkM/l68C4b3SEembhiNsQg==; 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: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:In-Reply-To:References; bh=fa23q4WVO2OnZtdDPUlhiH4A58a0OPA4ds05Wv5pCQ4=; b=WMsfXyu7VJS8ohHhNTX1zT6hVN j3jfI7XpSt3HG/KjVFg61rg1Z3w/wvrR4eWbDsOn81IS5Fq2WUEyhFQvFfXUaa1pdKBcA/YJUozLC 55DQFamOpuLBaXkhxJhsVGLghQKGyQyiyr7bG3qlE5J6jfhUNfnnHjQ/nX9yIUgVL370n8D5O8E8C 8jSZUCF8nK74VSijSrNhHVoU0JMHV62yyusSVjm1vylakWIlId0EElihmXQ7xy3ApM6NI3GJlDHeB Pb6CyuXQrDtpdUbxhBJ8ES+uiCYMW9EoXZQyPY+VtF86X0cIqxFWBROQO/xEgzwL06MC2jZFNKM60 sPy1MLGQ==; Received: by zero.zsh.org with local id 1qMFau-0002LO-B0; Wed, 19 Jul 2023 22:24:28 +0000 Authentication-Results: zsh.org; iprev=pass (mail-qt1-f175.google.com) smtp.remote-ip=209.85.160.175; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-qt1-f175.google.com ([209.85.160.175]:60586) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qMFaT-00021l-0u; Wed, 19 Jul 2023 22:24:06 +0000 Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-4039f7e1d3aso1774291cf.0 for ; Wed, 19 Jul 2023 15:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689805440; x=1690410240; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=fa23q4WVO2OnZtdDPUlhiH4A58a0OPA4ds05Wv5pCQ4=; b=G+kH4Bx13j/OYYVbfFz9LJdZudd+pIbL64xHTiaJIaZvIPa6+6DQwSgq1GYaTkpN/o T2a+y4nzN3feohH1ihjT1Xu2OEJPYIRZKNEEp+Bl7eE4P/syUFuGG6V5Anuw47DG9d2o OuH8S9NwPymL1C+hVGwouTfDGeb65/m0hssEGPEdaR3UPHkdnPjjTy7gyXHDgovgcG3H YYVFpLhefjlDyhGFa9lI57wHaPrU+RxA4hIMowtPP2Mql4Mo6x4gCjDJw2AEC4Rughgp JkjqGakmkGbOcxwG1WtgCbbQsKMmQ5lgB8wJLkBNsArsZUFQhM2zGVadScC6RXE4Zr9K rcWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689805440; x=1690410240; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fa23q4WVO2OnZtdDPUlhiH4A58a0OPA4ds05Wv5pCQ4=; b=F22goqAbGbMMQlSm/Q9ZI+gF0CbfoepaIeNqCAvmby+M2R4JP/8BPn9cevsNAvZYe1 OR0xFJABpJKLotOCILFCtzriKF808qzUUZO2+CYgRoC0WajthhWJiUktdzAB93hd2rt9 E/X7NGfNN1Gwiq+gYDcixjRSrr1a/tTiq+yvzhbwLjv/tJV58tv3PmgUzA/s6V+MBp2W 0NNrqKgf5jMcPEo+gE5pvgveazcaBGEplnqwLKwBRfXUKnw+MxVjz7WS+Mm+wHi2tAgd 1A1MZyi/yu9zrJzuK/bp+UoPalaN7M3m70Yim8RgCTk5hmQT74u4T3FvHL25NnGyCZzC gLRQ== X-Gm-Message-State: ABy/qLbLK94WPNdAmH47Tyc55clcjtRUoe3Njv5HW7scuiryavCEssop oARKSk5vMjYyHNi0+YI+L4KLgTbiMoKhFt6g6xoaz19+OzM= X-Google-Smtp-Source: APBJJlG2zJQicCpyff0iSPnEVnP3PacI/EtW4lnqpRCT0TUYJOW825AkFoLP281v6qlCECodDPLMpNVrFpKEUcklR0o= X-Received: by 2002:ac8:7d14:0:b0:403:a952:a6f8 with SMTP id g20-20020ac87d14000000b00403a952a6f8mr29733697qtb.31.1689805439418; Wed, 19 Jul 2023 15:23:59 -0700 (PDT) MIME-Version: 1.0 From: Alezender Tan Date: Wed, 19 Jul 2023 22:23:48 +0000 Message-ID: Subject: Segfault while using zsh/param/private module To: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="000000000000f4e3810600de7c47" X-Seq: 51966 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: --000000000000f4e3810600de7c47 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, I have the following piece of code involving the use of the zsh/param/private module that segfaults as seen below ``` =E2=9E=9C ~ zsh -f -x -c 'zmodload zsh/param/private function _TEST { private arg for arg in "${@}"; do case "${arg}" in test1=3D*) private test1=3D"${arg#*=3D}" ;; test2=3D*) private test2=3D"${arg#*=3D}" ;; esac done echo "test1=3D${test1}" echo "test2=3D${test2}" } _TEST test1=3D"" test2=3D""' +zsh:1> zmodload zsh/param/private +zsh:20> _TEST 'test1=3D' 'test2=3D' +_TEST:1> private arg +_TEST:2> arg=3Dtest1=3D +_TEST:3> case test1=3D (test1=3D*) +_TEST:5> private 'test1=3D' +_TEST:2> arg=3Dtest2=3D +_TEST:3> case test2=3D (test1=3D*) +_TEST:3> case test2=3D (test2=3D*) +_TEST:9> private 'test2=3D' [1] 3152586 segmentation fault (core dumped) zsh -f -x -c ``` It's happening on the latest version of zsh which I installed using brew on Ubuntu 20.04 (was using 5.8 installed via apt but uninstalled to check if the issue was still occurring on 5.9) ``` =E2=9E=9C ~ zsh --version zsh 5.9 (x86_64-pc-linux-gnu) =E2=9E=9C ~ brew info zsh =3D=3D> zsh: stable 5.9 (bottled), HEAD UNIX shell (command interpreter) https://www.zsh.org/ /home/linuxbrew/.linuxbrew/Cellar/zsh/5.9 (1,578 files, 14.9MB) * Poured from bottle using the formulae.brew.sh API on 2023-07-19 at 22:38:08 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/zsh.rb License: MIT-Modern-Variant =3D=3D> Dependencies Build: texinfo =E2=9C=98 Required: ncurses =E2=9C=94, pcre =E2=9C=94, gcc =E2=9C=94, glibc =E2=9C=94 =3D=3D> Options --HEAD Install HEAD version =3D=3D> Analytics install: 7,575 (30 days), 28,511 (90 days), 38,178 (365 days) install-on-request: 7,409 (30 days), 27,934 (90 days), 37,383 (365 days) build-error: 0 (30 days) ``` The segfault occurs regardless of whether `test1` and `test2` are empty or non-empty strings as seen below ``` =E2=9E=9C ~ zsh -f -x -c 'zmodload zsh/param/private function _TEST { private arg for arg in "${@}"; do case "${arg}" in test1=3D*) private test1=3D"${arg#*=3D}" ;; test2=3D*) private test2=3D"${arg#*=3D}" ;; esac done echo "test1=3D${test1}" echo "test2=3D${test2}" } _TEST test1=3D"test3" test2=3D"test4"' +zsh:1> zmodload zsh/param/private +zsh:20> _TEST 'test1=3Dtest3' 'test2=3Dtest4' +_TEST:1> private arg +_TEST:2> arg=3Dtest1=3Dtest3 +_TEST:3> case test1=3Dtest3 (test1=3D*) +_TEST:5> private 'test1=3Dtest3' +_TEST:2> arg=3Dtest2=3Dtest4 +_TEST:3> case test2=3Dtest4 (test1=3D*) +_TEST:3> case test2=3Dtest4 (test2=3D*) +_TEST:9> private 'test2=3Dtest4' [1] 3155156 segmentation fault (core dumped) zsh -f -x -c ``` But strangely enough, does not happen when `test2` is omitted from the code altogether as seen below ``` =E2=9E=9C ~ zsh -f -x -c 'zmodload zsh/param/private function _TEST { private arg for arg in "${@}"; do case "${arg}" in test1=3D*) private test1=3D"${arg#*=3D}" ;; esac done echo "test1=3D${test1}" } _TEST test1=3D""' +zsh:1> zmodload zsh/param/private +zsh:15> _TEST 'test1=3D' +_TEST:1> private arg +_TEST:2> arg=3Dtest1=3D +_TEST:3> case test1=3D (test1=3D*) +_TEST:5> private 'test1=3D' +_TEST:10> echo 'test1=3D' test1=3D ``` It does, however, happen for 2 or more cases and somehow gets to the very end before segfault-ing instead of doing so by the second case ``` =E2=9E=9C ~ zsh -f -x -c 'zmodload zsh/param/private function _TEST { private arg for arg in "${@}"; do case "${arg}" in test1=3D*) private test1=3D"${arg#*=3D}" ;; test2=3D*) private test2=3D"${arg#*=3D}" ;; test3=3D*) private test3=3D"${arg#*=3D}" ;; esac done echo "test1=3D${test1}" echo "test2=3D${test2}" <.... +zsh:1> zmodload zsh/param/private +zsh:25> _TEST 'test1=3D' 'test2=3D' 'test3=3D' +_TEST:1> private arg +_TEST:2> arg=3Dtest1=3D +_TEST:3> case test1=3D (test1=3D*) +_TEST:5> private 'test1=3D' +_TEST:2> arg=3Dtest2=3D +_TEST:3> case test2=3D (test1=3D*) +_TEST:3> case test2=3D (test2=3D*) +_TEST:9> private 'test2=3D' +_TEST:2> arg=3Dtest3=3D +_TEST:3> case test3=3D (test1=3D*) +_TEST:3> case test3=3D (test2=3D*) +_TEST:3> case test3=3D (test3=3D*) +_TEST:13> private 'test3=3D' [1] 3154406 segmentation fault (core dumped) zsh -f -x -c ``` One easy workaround is to declare the `private` variables outside the for loop as seen below ``` =E2=9E=9C ~ zsh -f -x -c 'zmodload zsh/param/private function _TEST { private arg test1 test2 for arg in "${@}"; do case "${arg}" in test1=3D*) test1=3D"${arg#*=3D}" ;; test2=3D*) test2=3D"${arg#*=3D}" ;; esac done echo "test1=3D${test1}" echo "test2=3D${test2}" } _TEST test1=3D"" test2=3D""' +zsh:1> zmodload zsh/param/private +zsh:20> _TEST 'test1=3D' 'test2=3D' +_TEST:1> private arg test1 test2 +_TEST:2> arg=3Dtest1=3D +_TEST:3> case test1=3D (test1=3D*) +_TEST:5> test1=3D'' +_TEST:2> arg=3Dtest2=3D +_TEST:3> case test2=3D (test1=3D*) +_TEST:3> case test2=3D (test2=3D*) +_TEST:9> test2=3D'' +_TEST:14> echo 'test1=3D' test1=3D +_TEST:15> echo 'test2=3D' test2=3D ``` but I still think it's a bug because why would the single case scenario work but not the multi-case scenario? I also tried `local -P` instead of `private` but it yielded the same segfault ``` =E2=9E=9C ~ zsh -f -x -c 'zmodload zsh/param/private function _TEST { local -P arg for arg in "${@}"; do case "${arg}" in test1=3D*) local -P test1=3D"${arg#*=3D}" ;; test2=3D*) local -P test2=3D"${arg#*=3D}" ;; esac done echo "test1=3D${test1}" echo "test2=3D${test2}" } _TEST test1=3D"" test2=3D""' +zsh:1> zmodload zsh/param/private +zsh:20> _TEST 'test1=3D' 'test2=3D' +_TEST:1> local -P arg +_TEST:2> arg=3Dtest1=3D +_TEST:3> case test1=3D (test1=3D*) +_TEST:5> local -P test1=3D'' +_TEST:2> arg=3Dtest2=3D +_TEST:3> case test2=3D (test1=3D*) +_TEST:3> case test2=3D (test2=3D*) +_TEST:9> local -P test2=3D'' [1] 3158070 segmentation fault (core dumped) zsh -f -x -c ``` The `local` keyword works fine but it obviously doesn't limit the scope of the variables as much as `private` ``` =E2=9E=9C ~ zsh -f -x -c 'zmodload zsh/param/private function _TEST { local arg for arg in "${@}"; do case "${arg}" in test1=3D*) local test1=3D"${arg#*=3D}" ;; test2=3D*) local test2=3D"${arg#*=3D}" ;; esac done echo "test1=3D${test1}" echo "test2=3D${test2}" } _TEST test1=3D"" test2=3D""' +zsh:1> zmodload zsh/param/private +zsh:20> _TEST 'test1=3D' 'test2=3D' +_TEST:1> local arg +_TEST:2> arg=3Dtest1=3D +_TEST:3> case test1=3D (test1=3D*) +_TEST:5> local test1=3D'' +_TEST:2> arg=3Dtest2=3D +_TEST:3> case test2=3D (test1=3D*) +_TEST:3> case test2=3D (test2=3D*) +_TEST:9> local test2=3D'' +_TEST:14> echo 'test1=3D' test1=3D +_TEST:15> echo 'test2=3D' test2=3D ``` I don't know if this bug has been reported before, so please do reply to this email if it is already being worked on (it would also be nice to know if it was a new find). Otherwise, I hope to see this fixed some time in the future. Best regards, TAN Wei Xin, Alez --000000000000f4e3810600de7c47 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,=C2=A0

I have the foll= owing piece of code involving the use of the zsh/param/private module that = segfaults as seen below
```
=E2=9E=9C =C2=A0~ zsh -= f -x -c 'zmodload zsh/param/private
function _TEST {
=C2=A0 priva= te arg
=C2=A0 for arg in "${@}"; do
=C2=A0 =C2=A0 case &quo= t;${arg}" in
=C2=A0 =C2=A0 =C2=A0 test1=3D*)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 private test1=3D"${arg#*=3D}"
=C2=A0 =C2=A0 =C2=A0 = ;;

=C2=A0 =C2=A0 =C2=A0 test2=3D*)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 pr= ivate test2=3D"${arg#*=3D}"
=C2=A0 =C2=A0 =C2=A0 ;;
=C2=A0 = =C2=A0 esac
=C2=A0done

=C2=A0echo "test1=3D${test1}"=C2=A0echo "test2=3D${test2}"
}

_TEST test1=3D"&q= uot; test2=3D""'
+zsh:1> zmodload zsh/param/private
= +zsh:20> _TEST 'test1=3D' 'test2=3D'
+_TEST:1> pri= vate arg
+_TEST:2> arg=3Dtest1=3D
+_TEST:3> case test1=3D (test= 1=3D*)
+_TEST:5> private 'test1=3D'
+_TEST:2> arg=3Dtes= t2=3D
+_TEST:3> case test2=3D (test1=3D*)
+_TEST:3> case test2= =3D (test2=3D*)
+_TEST:9> private 'test2=3D'
[1] =C2=A0 = =C2=A03152586 segmentation fault (core dumped) =C2=A0zsh -f -x -c
```

It's happening on the latest version of zsh whic= h I installed using brew on Ubuntu 20.04 (was using 5.8 installed via apt b= ut uninstalled to check if the issue was still occurring on 5.9)
```
= =E2=9E=9C =C2=A0~ zsh --version
zsh 5.9 (x86_64-pc-linux-gnu)
=E2=9E= =9C =C2=A0~ brew info zsh
=3D=3D> zsh: stable 5.9 (bottled), HEAD
= UNIX shell (command interpreter)
https:= //www.zsh.org/
/home/linuxbrew/.linuxbrew/Cellar/zsh/5.9 (1,578 file= s, 14.9MB) *
=C2=A0 Poured from bottle using the formulae.brew.sh API on 2023-07-19 at 22:38:08
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/zsh.rbLicense: MIT-Modern-Variant
=3D=3D> Dependencies
Build: texinfo = =E2=9C=98
Required: ncurses =E2=9C=94, pcre =E2=9C=94, gcc =E2=9C=94, gl= ibc =E2=9C=94
=3D=3D> Options
--HEAD
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 Install HEAD version
=3D=3D> Analytics
install: 7,575 (30 days= ), 28,511 (90 days), 38,178 (365 days)
install-on-request: 7,409 (30 day= s), 27,934 (90 days), 37,383 (365 days)
build-error: 0 (30 days)
```<= br>
The segfault occurs regardless of whether `test1` and `te= st2` are empty or non-empty strings as seen below
```
= =E2=9E=9C =C2=A0~ zsh -f -x -c 'zmodload zsh/param/private
function = _TEST {
=C2=A0 private arg
=C2=A0 for arg in "${@}"; do
= =C2=A0 =C2=A0 case "${arg}" in
=C2=A0 =C2=A0 =C2=A0 test1=3D*)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 private test1=3D"${arg#*=3D}"
= =C2=A0 =C2=A0 =C2=A0 ;;

=C2=A0 =C2=A0 =C2=A0 test2=3D*)
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 private test2=3D"${arg#*=3D}"
=C2=A0 =C2= =A0 =C2=A0 ;;
=C2=A0 =C2=A0 esac
=C2=A0done

=C2=A0echo "t= est1=3D${test1}"
=C2=A0echo "test2=3D${test2}"
}
_TEST test1=3D"test3" test2=3D"test4"'
+zsh:1&= gt; zmodload zsh/param/private
+zsh:20> _TEST 'test1=3Dtest3'= 'test2=3Dtest4'
+_TEST:1> private arg
+_TEST:2> arg=3D= test1=3Dtest3
+_TEST:3> case test1=3Dtest3 (test1=3D*)
+_TEST:5>= ; private 'test1=3Dtest3'
+_TEST:2> arg=3Dtest2=3Dtest4
+_= TEST:3> case test2=3Dtest4 (test1=3D*)
+_TEST:3> case test2=3Dtest= 4 (test2=3D*)
+_TEST:9> private 'test2=3Dtest4'
[1] =C2=A0= =C2=A03155156 segmentation fault (core dumped) =C2=A0zsh -f -x -c
```

But strangely enough, does not happen wh= en `test2` is omitted from the code altogether as seen below
```
=E2= =9E=9C =C2=A0~ zsh -f -x -c 'zmodload zsh/param/private
function _TE= ST {
=C2=A0 private arg
=C2=A0 for arg in "${@}"; do
=C2= =A0 =C2=A0 case "${arg}" in
=C2=A0 =C2=A0 =C2=A0 test1=3D*)=C2=A0 =C2=A0 =C2=A0 =C2=A0 private test1=3D"${arg#*=3D}"
=C2= =A0 =C2=A0 =C2=A0 ;;
=C2=A0 =C2=A0 esac
=C2=A0done

=C2=A0echo = "test1=3D${test1}"
}

_TEST test1=3D""'+zsh:1> zmodload zsh/param/private
+zsh:15> _TEST 'test1=3D&#= 39;
+_TEST:1> private arg
+_TEST:2> arg=3Dtest1=3D
+_TEST:3&= gt; case test1=3D (test1=3D*)
+_TEST:5> private 'test1=3D'+_TEST:10> echo 'test1=3D'
test1=3D
```

It does, however, happen for 2 or more cases and somehow gets to the very = end before segfault-ing instead of doing so by the second case
``= `
=E2=9E=9C =C2=A0~ zsh -f -x -c 'zmodload zsh/param/private<= br>function _TEST {
=C2=A0 private arg
=C2=A0 for arg in "${@}&q= uot;; do
=C2=A0 =C2=A0 case "${arg}" in
=C2=A0 =C2=A0 =C2= =A0 test1=3D*)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 private test1=3D"${arg#*= =3D}"
=C2=A0 =C2=A0 =C2=A0 ;;

=C2=A0 =C2=A0 =C2=A0 test2=3D*= )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 private test2=3D"${arg#*=3D}"=C2=A0 =C2=A0 =C2=A0 ;;

=C2=A0 =C2=A0 =C2=A0 test3=3D*)
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 private test3=3D"${arg#*=3D}"
=C2=A0 =C2= =A0 =C2=A0 ;;
=C2=A0 =C2=A0 esac
=C2=A0done

=C2=A0echo "t= est1=3D${test1}"
=C2=A0echo "test2=3D${test2}" =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 <....
+zsh:1> zmodload zsh/param/private
+zsh:25> _TE= ST 'test1=3D' 'test2=3D' 'test3=3D'
+_TEST:1>= private arg
+_TEST:2> arg=3Dtest1=3D
+_TEST:3> case test1=3D (= test1=3D*)
+_TEST:5> private 'test1=3D'
+_TEST:2> arg= =3Dtest2=3D
+_TEST:3> case test2=3D (test1=3D*)
+_TEST:3> case = test2=3D (test2=3D*)
+_TEST:9> private 'test2=3D'
+_TEST:2= > arg=3Dtest3=3D
+_TEST:3> case test3=3D (test1=3D*)
+_TEST:3&g= t; case test3=3D (test2=3D*)
+_TEST:3> case test3=3D (test3=3D*)
+= _TEST:13> private 'test3=3D'
[1] =C2=A0 =C2=A03154406 segment= ation fault (core dumped) =C2=A0zsh -f -x -c
```
One easy workaround is to declare the `private` variables outs= ide the for loop as seen below
```
=E2=9E=9C =C2=A0~ zs= h -f -x -c 'zmodload zsh/param/private
function _TEST {
=C2=A0 pr= ivate arg test1 test2
=C2=A0 for arg in "${@}"; do
=C2=A0 = =C2=A0 case "${arg}" in
=C2=A0 =C2=A0 =C2=A0 test1=3D*)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 test1=3D"${arg#*=3D}"
=C2=A0 =C2=A0 = =C2=A0 ;;

=C2=A0 =C2=A0 =C2=A0 test2=3D*)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 test2=3D"${arg#*=3D}"
=C2=A0 =C2=A0 =C2=A0 ;;
=C2=A0= =C2=A0 esac
=C2=A0done

=C2=A0echo "test1=3D${test1}"=C2=A0echo "test2=3D${test2}"
}

_TEST test1=3D"&= quot; test2=3D""'
+zsh:1> zmodload zsh/param/private+zsh:20> _TEST 'test1=3D' 'test2=3D'
+_TEST:1> pr= ivate arg test1 test2
+_TEST:2> arg=3Dtest1=3D
+_TEST:3> case t= est1=3D (test1=3D*)
+_TEST:5> test1=3D''
+_TEST:2> arg= =3Dtest2=3D
+_TEST:3> case test2=3D (test1=3D*)
+_TEST:3> case = test2=3D (test2=3D*)
+_TEST:9> test2=3D''
+_TEST:14> ec= ho 'test1=3D'
test1=3D
+_TEST:15> echo 'test2=3D'<= br>test2=3D
```
but I still think it's a bug becaus= e why would the single case scenario work but not the multi-case scenario?<= /div>

I also tried `local -P` instead of `private` but i= t yielded the same segfault
```
=E2=9E=9C =C2=A0~ zsh -= f -x -c 'zmodload zsh/param/private
function _TEST {
=C2=A0 local= -P arg
=C2=A0 for arg in "${@}"; do
=C2=A0 =C2=A0 case &qu= ot;${arg}" in
=C2=A0 =C2=A0 =C2=A0 test1=3D*)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 local -P test1=3D"${arg#*=3D}"
=C2=A0 =C2=A0 =C2=A0= ;;

=C2=A0 =C2=A0 =C2=A0 test2=3D*)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 l= ocal -P test2=3D"${arg#*=3D}"
=C2=A0 =C2=A0 =C2=A0 ;;
=C2= =A0 =C2=A0 esac
=C2=A0done

=C2=A0echo "test1=3D${test1}"= ;
=C2=A0echo "test2=3D${test2}"
}

_TEST test1=3D&quo= t;" test2=3D""'
+zsh:1> zmodload zsh/param/private=
+zsh:20> _TEST 'test1=3D' 'test2=3D'
+_TEST:1>= local -P arg
+_TEST:2> arg=3Dtest1=3D
+_TEST:3> case test1=3D = (test1=3D*)
+_TEST:5> local -P test1=3D''
+_TEST:2> arg= =3Dtest2=3D
+_TEST:3> case test2=3D (test1=3D*)
+_TEST:3> case = test2=3D (test2=3D*)
+_TEST:9> local -P test2=3D''
[1] =C2= =A0 =C2=A03158070 segmentation fault (core dumped) =C2=A0zsh -f -x -c
=
```

The `local` keyword works fine but it obv= iously doesn't limit the scope of the variables as much as `private`
```
=E2=9E=9C =C2=A0~ zsh -f -x -c 'zmodload zsh/para= m/private
function _TEST {
=C2=A0 local arg
=C2=A0 for arg in &quo= t;${@}"; do
=C2=A0 =C2=A0 case "${arg}" in
=C2=A0 =C2= =A0 =C2=A0 test1=3D*)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 local test1=3D"${= arg#*=3D}"
=C2=A0 =C2=A0 =C2=A0 ;;

=C2=A0 =C2=A0 =C2=A0 test= 2=3D*)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 local test2=3D"${arg#*=3D}"=
=C2=A0 =C2=A0 =C2=A0 ;;
=C2=A0 =C2=A0 esac
=C2=A0done

=C2= =A0echo "test1=3D${test1}"
=C2=A0echo "test2=3D${test2}&q= uot;
}

_TEST test1=3D"" test2=3D""'
+z= sh:1> zmodload zsh/param/private
+zsh:20> _TEST 'test1=3D'= 'test2=3D'
+_TEST:1> local arg
+_TEST:2> arg=3Dtest1= =3D
+_TEST:3> case test1=3D (test1=3D*)
+_TEST:5> local test1= =3D''
+_TEST:2> arg=3Dtest2=3D
+_TEST:3> case test2=3D = (test1=3D*)
+_TEST:3> case test2=3D (test2=3D*)
+_TEST:9> local= test2=3D''
+_TEST:14> echo 'test1=3D'
test1=3D+_TEST:15> echo 'test2=3D'
test2=3D
```
=
I don't know if this bug has been reported before, so pl= ease do reply to this email if it is already being worked on (it would also= be nice to know if it was a new find).
Otherwise, I hope to see = this fixed some time in the future.

Best regards,
TAN Wei Xin, Alez
--000000000000f4e3810600de7c47--