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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,
T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4
Received: (qmail 30386 invoked from network); 12 May 2023 09:28:41 -0000
Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368)
by inbox.vuxu.org with ESMTPUTF8; 12 May 2023 09:28:41 -0000
ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1683883721;
b=ciZZ0wDnp4BXx+P6xT/pwCQC0epJ9LFrbcZs435J5s2lK0su/hlv+7gqFlX3ocNYmkWH2RGhSb
+gdlz/uPRE4oZmq4MF4DAMZY7Kb2CdxgHKjn65y+ePjnQ1vnLYYbmdiFkeWl0qGwuvGY7T0i7l
t7UUg/Y7GtBLuOoc0OX3nb/zOHl4P57gQSppoey7dufzrRujgzT4akndKKfZzMshVFQ/D+DaK3
PdbKnsOco6hvmo1qaj77F3rIsgCVpZSSsc4axpxluJ/wER79R/aUqNZI8X8sLjSjLDWgqHwLQD
ewqUwV35ulqLJd8skDZILfjtniSZ+Zb6MRe1nTr+mUVjkA==;
ARC-Authentication-Results: i=1; zsh.org;
iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1683883721;
bh=KQjDUHLUzM/V9UvOZUv9fBcsA68dPe2qhdWSbsu/8X4=;
h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help:
List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:
References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature:
DKIM-Signature;
b=D3odfgaRQRByoupd0gkNu/RF6Csj7KoVsIpf9II6zUTMk7zXLXeYWkRfVYfWQf1dP3n281oD2M
YL+LPAfNuXcZ55yS/tkyxib7jP/4OO0m8+0Ml9iyqvkEl2YBJrLXttURYXxPsbgiv6wLjQ2Dnq
s1C/3Cc3ggULIw3R28+LfD1M4S8i61GXRYmEg/pCOFyukE0F9t/OacjgSS1b5JEdA+C24LEglK
C4bQGoGQLdygf9QZ+d1nhXBwIGEB2kyL7LxzXLcvaEj8Ea82Ns4iCtxA21X9P7grma5kqwkbpj
JGziSWUjIP77+A4ZE1xtil0fQ+/lbGJ0VOM0HBqhUw3Xqg==;
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-Transfer-Encoding:
Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From:
Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:
Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;
bh=LkuJ5drq8G+jsGApNV+GHI1jONWRG1Kj6dxeDuQMRwA=; b=LiWxp6jwz4FxK1FRBBnw3BTSlJ
6ci/GZDNRIpHNu+LMxgrZgbDOfMMJrv4s0lmJnFR46tzLbw7JQGzNVhxEJ/jKLi8oDyIPm/P7Zmex
/gQYXzvBhy8f09Z+mms8nWZO/0R3AyIvNLAgad1crOapBZk/5Axy3s/j+7ULUw4YgW3wHWlIVVsji
w5EZcXiO2EMlPhBHkXc7poL5NeNuRh8kpfAbF6usP10rADS5vgzd0qWqkgh7rroKWaeq1dRNUIfTP
82+fg7r25Oib8fSEih9L4TIwgEOLDgnE3GQwl79YOcTaTDj5l9o4ksQ9+QIAR8g6VCgu7EwifunmQ
VAjbmnJw==;
Received: by zero.zsh.org with local
id 1pxP4o-000AhP-Mj;
Fri, 12 May 2023 09:28:38 +0000
Authentication-Results: zsh.org;
iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
Received: from smtpq2.tb.ukmail.iss.as9143.net ([212.54.57.97]:33408)
by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
id 1pxP4S-000APZ-KK;
Fri, 12 May 2023 09:28:17 +0000
Received: from [212.54.57.82] (helo=smtp3.tb.ukmail.iss.as9143.net)
by smtpq2.tb.ukmail.iss.as9143.net with esmtp (Exim 4.90_1)
(envelope-from
)
id 1pxP4S-0000lq-8R
for zsh-workers@zsh.org; Fri, 12 May 2023 11:28:16 +0200
Received: from oxbe21.tb.ukmail.iss.as9143.net ([172.25.160.152])
by smtp3.tb.ukmail.iss.as9143.net with ESMTP
id xP4RpVNMQvML8xP4Sp9Nd9; Fri, 12 May 2023 11:28:16 +0200
X-Env-Mailfrom: p.w.stephenson@ntlworld.com
X-Env-Rcptto: zsh-workers@zsh.org
X-SourceIP: 172.25.160.152
X-CNFS-Analysis: v=2.4 cv=NuYXMeRJ c=1 sm=1 tr=0 ts=645e06b0 cx=a_exe
a=I3kh1BFku3bnNore5KbC7A==:117 a=1DWFKdCB1IcA:10 a=IkcTkHD0fZMA:10
a=2tcQwhWb79dv4gY6GfQA:9 a=QEXdDO2ut3YA:10 a=75Kt_H3ikK-EkTT1woid:22
X-Authenticated-Sender: p.w.stephenson@ntlworld.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com;
s=meg.feb2017; t=1683883696;
bh=KQjDUHLUzM/V9UvOZUv9fBcsA68dPe2qhdWSbsu/8X4=;
h=Date:From:To:In-Reply-To:References:Subject;
b=01fttDqSQ+CaXWCQGKqwtn5JVMsuOxjLpIsOy6w61CJRK4yeWK9X5DMIR2qzvmC3w
B20pu6ShYNOXx3W8HYmnzNbbj7EAe1ZHHDpePMLGQR1FAbQOh4ueX70n3rBs2BNEjC
3oNxCgfmwCNYkv0mfgCSLgts9XUod2WH7W2F7WShoWm3IVoQpR/P9MAtYSMnLKKU/p
MnyY7JvQ7Wmy02blSL374Z8dni30AoQwFcqgnghRmZ2z+JKsqHj2pvlgLRCSMpv6We
aqroILWgVIzNNDrWT4EGeYJey+z9IkEswUgQvYVWHhA+cfTsun034MhyGP7kUFvJvF
nAniFQSz2JUGg==
Date: Fri, 12 May 2023 10:28:15 +0100 (BST)
From: Peter Stephenson
To: zsh-workers@zsh.org
Message-ID: <786956771.10261130.1683883695977@mail.virginmedia.com>
In-Reply-To: <290263641.10091739.1683707984531@mail.virginmedia.com>
References:
<76e1d7d098d80e2c8bb9746ba964a0fbd41cc140.camel@ntlworld.com>
<290263641.10091739.1683707984531@mail.virginmedia.com>
Subject: Re: Bug: Searching through sufficiently large $historywords causes
seg fault
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Priority: 3
Importance: Normal
X-Mailer: Open-Xchange Mailer
X-Originating-IP: 147.161.224.167
X-Originating-Client: open-xchange-appsuite
X-CMAE-Envelope: MS4xfI2ER31TXl9ZizgJle9PXzJpXbiTNxSbZIJKWwwmMym9YSPbWjYW9lkoUatODMTpatOIfp+/CsIG9mynRLu1hWtzFjrILt6ZZyv0+Ks2yJw1QvWEd7sg
v9mBmgzkFFAi+9jGzEeiF0lDnGCUb9a5zu/utDBk/naqGFDedD3qkZkeDQnKev3QtwYhYxrutMlpI1ZPBVtz8mV8cCo41znudLCmrZYThiIJSSk5SVf0CqsJ
X-Seq: 51739
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:
> Tracking down all possible cases where a history word number can be
> calculated wrongly from any possible source is another thing entirely.
> Possibly some DPUTS() in the earlier code are a good idea, as now we
> know it is showing up in error later on trapping it there isn't going
> to help any more.
Here's the only obvious case I can see in normal history management
where you might get a miscalculation, though why is obscure as this
seems only to be connected to skipping a !-history expansion. IF
this pops up hopefully you'll be able to work out how to reproduce
it.
The history reading mechanism from a file remains a suspect as it's
much more obscure, and is consequently harder to instrument usefully.
I'll commit the other patch this weekend: I think we have enough
information to be able to continue searches without having to have
the shell crash for us.
pws
diff --git a/Src/hist.c b/Src/hist.c
index 82d03a840..7e6394406 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -1643,12 +1643,17 @@ hend(Eprog prog)
void
ihwbegin(int offset)
{
+ int pos = hptr - chline + offset;
if (stophist == 2 || (histactive & HA_INWORD) ||
(inbufflags & (INP_ALIAS|INP_HIST)) == INP_ALIAS)
return;
if (chwordpos%2)
chwordpos--; /* make sure we're on a word start, not end */
- chwords[chwordpos++] = hptr - chline + offset;
+ DPUTS1(pos < 0, "History word position < 0 in %s",
+ dupstrpfx(chline, hptr-chline));
+ if (pos < 0)
+ pos = 0;
+ chwords[chwordpos++] = pos;
}
/* Abort current history word, not needed */