From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] sigsegv
Date: Wed, 3 May 2023 15:56:05 +0000 [thread overview]
Message-ID: <CAKc7PVC44P2bV+dur-731bZyMNxmh5dM09eN91fS-DFfxmU0jQ@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVAcu-GOZBStWzNprWP1D742c2R5oCWxGy5etbeuH5PWOw@mail.gmail.com>
Adding wend<0 to the break-if helps for the crash:
+ if (wbegin >= len || wend > len||wend<0)
+ break;
Pressing Alt-/ at empty line yields:
16:52[*cal/share/zinit/plugins/zsh]1# !
(git)-[master●]
zsh: do you wish to see all 1048 possibilities (1080 lines)?
I wonder if 1080 is a much less value than the maximum? Why ! appears
after Alt-/ ? I'm confused if it limits the results?
On Wed, 3 May 2023 at 15:35, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> The error occurs with patch. I've played around in gdb:
>
> (gdb) p (int)(e-hstr)
> $65 = -31903
>
> This should be positive – e points to a \0 inserted in hstr. That's
> why printing e shows unexpected values. How come wend became negative?
>
> On Sun, 30 Apr 2023 at 17:31, Peter Stephenson
> <p.w.stephenson@ntlworld.com> wrote:
> >
> > On Sat, 2023-04-29 at 10:52 +0000, Sebastian Gniazdowski wrote:
> > > It says "incomplete sequence \339" although egrep $'\330' ~/.zhistory
> > > doesn't return anything…
> >
> > So it looks like this is probably confusion over bad or incomplete
> > multibyte characters again.
> >
> > Rather than bufferwords() --- I think that's not relevant at this point
> > --- this could be the code that reads a history line back into the buffer
> > and divides it into words getting confused. This is different from
> > the code that adds to a history line when it's first generated and
> > likely to be less accurate --- and also fits better with the
> > reproducibility of this problem.
> >
> > Anyway, given there's no single place where the line originates,
> > and given that we're probably not going to be able to turn it into
> > a proper line if the there's not a complete character sequence,
> > safety at the point in question is probably the best we've got.
> >
> > See if this helps.
> >
> > pws
> >
> > diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
> > index 96a211c69..2067f5bab 100644
> > --- a/Src/Modules/parameter.c
> > +++ b/Src/Modules/parameter.c
> > @@ -1233,9 +1233,16 @@ histwgetfn(UNUSED(Param pm))
> > pushnode(l, getdata(n));
> >
> > while (he) {
> > + char *hstr = he->node.nam;
> > + int len = strlen(hstr);
> > for (iw = he->nwords - 1; iw >= 0; iw--) {
> > - h = he->node.nam + he->words[iw * 2];
> > - e = he->node.nam + he->words[iw * 2 + 1];
> > + int wbegin = he->words[iw * 2];
> > + int wend = he->words[iw * 2 + 1];
> > +
> > + if (wbegin >= len || wend > len)
> > + break;
> > + h = hstr + wbegin;
> > + e = hstr + wend;
> > sav = *e;
> > *e = '\0';
> > addlinknode(l, dupstring(h));
> >
> >
>
>
> --
> Best regards,
> Sebastian Gniazdowski
--
Best regards,
Sebastian Gniazdowski
next prev parent reply other threads:[~2023-05-03 15:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-25 13:48 Sebastian Gniazdowski
2023-04-25 13:56 ` Peter Stephenson
2023-04-28 11:25 ` Sebastian Gniazdowski
2023-04-28 11:41 ` Peter Stephenson
2023-04-28 14:13 ` Sebastian Gniazdowski
2023-04-28 14:22 ` Peter Stephenson
2023-04-29 10:52 ` Sebastian Gniazdowski
2023-04-30 9:51 ` Sebastian Gniazdowski
2023-04-30 17:30 ` Peter Stephenson
2023-05-03 15:35 ` Sebastian Gniazdowski
2023-05-03 15:56 ` Sebastian Gniazdowski [this message]
2023-05-03 16:25 ` Peter Stephenson
2023-05-03 21:13 ` Bart Schaefer
[not found] ` <CAKc7PVDt6hS26DxC3hDE-ziMXm-K1jqbJXghynpp-ZhpdN_LLw@mail.gmail.com>
2023-05-04 15:01 ` Bart Schaefer
2023-05-05 18:54 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKc7PVC44P2bV+dur-731bZyMNxmh5dM09eN91fS-DFfxmU0jQ@mail.gmail.com \
--to=sgniazdowski@gmail.com \
--cc=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).