From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id b0e873c8 for ; Sun, 26 Jan 2020 01:17:44 +0000 (UTC) Received: (qmail 11611 invoked by alias); 26 Jan 2020 01:17:39 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45343 Received: (qmail 3601 invoked by uid 1010); 26 Jan 2020 01:17:39 -0000 X-Qmail-Scanner-Diagnostics: from wout1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25699. spamassassin: 3.4.2. Clear:RC:0(64.147.123.24):SA:0(-1.9/5.0):. Processed in 0.912667 secs); 26 Jan 2020 01:17:39 -0000 X-Envelope-From: danielsh@apache.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: softfail (ns1.primenet.com.au: transitioning SPF record at amazonses.com does not designate 64.147.123.24 as permitted sender) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrvdekgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffogggtgfesthekredtre dtjeenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurghnihgvlhhshhesrghp rggthhgvrdhorhhgqeenucfkphepjeelrddukedtrdehjedrudduleenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurghnihgvlhhshhesrghp rggthhgvrdhorhhg X-ME-Proxy: From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] Queue signals around arithmetic evaluations Date: Sun, 26 Jan 2020 01:17:00 +0000 Message-Id: <20200126011700.7200-1-danielsh@apache.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The queueing added in execarith() in 45083 is reverted since the callee does this now. --- I've been using the math.c part of this for a while and haven't noticed any problems. I was using that on top of a change that added signal queueing in some calls to matheval*(), though. I assume this is still safe enough to be pushed to 5.8, though. The log message of 45083 said the reason signal queueing is needed here is to prevent "re-entrancy in memory functions when setting variables". I assume this refers to expressions such as «(( x = 5 ))», but which memory functions are referred to here? I don't have a clear picture in my head of what bug this patch is supposed to be fixing. Cheers, Daniel Src/exec.c | 3 --- Src/math.c | 15 +++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Src/exec.c b/Src/exec.c index fac095d64..50027654a 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -5101,7 +5101,6 @@ execarith(Estate state, UNUSED(int do_exec)) mnumber val = zero_mnumber; int htok = 0; - queue_signals(); if (isset(XTRACE)) { printprompt4(); fprintf(xtrerr, "(("); @@ -5121,8 +5120,6 @@ execarith(Estate state, UNUSED(int do_exec)) fprintf(xtrerr, " ))\n"); fflush(xtrerr); } - unqueue_signals(); - if (errflag) { errflag &= ~ERRFLAG_ERROR; return 2; diff --git a/Src/math.c b/Src/math.c index a38770073..905b910ec 100644 --- a/Src/math.c +++ b/Src/math.c @@ -1133,8 +1133,7 @@ notzero(mnumber a) /* macro to pop three values off the value stack */ -/**/ -void +static void op(int what) { mnumber a, b, c, *spval; @@ -1569,14 +1568,19 @@ mathparse(int pc) if (errflag) return; + queue_signals(); mtok = zzlex(); /* Handle empty input */ - if (pc == TOPPREC && mtok == EOI) + if (pc == TOPPREC && mtok == EOI) { + unqueue_signals(); return; + } checkunary(mtok, optr); while (prec[mtok] <= pc) { - if (errflag) + if (errflag) { + unqueue_signals(); return; + } switch (mtok) { case NUM: push(yyval, NULL, 0); @@ -1595,6 +1599,7 @@ mathparse(int pc) if (mtok != M_OUTPAR) { if (!errflag) zerr("bad math expression: ')' expected"); + unqueue_signals(); return; } break; @@ -1613,6 +1618,7 @@ mathparse(int pc) if (mtok != COLON) { if (!errflag) zerr("bad math expression: ':' expected"); + unqueue_signals(); return; } if (q) @@ -1636,4 +1642,5 @@ mathparse(int pc) mtok = zzlex(); checkunary(mtok, optr); } + unqueue_signals(); }