zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Cc: Patrick Hilhorst <patrickhilhorst97@gmail.com>
Subject: Re: Crash on tab completion
Date: Mon, 5 Sep 2016 21:27:24 +0100	[thread overview]
Message-ID: <20160905212724.1d05ed9e@ntlworld.com> (raw)
In-Reply-To: <CAH+w=7ZT=erqkQf=aFHh8r4Hdk6oBN+gtMs2F9y6fGQAWqMSdQ@mail.gmail.com>

On Mon, 5 Sep 2016 10:18:57 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Mon, Sep 5, 2016 at 3:42 AM, Patrick Hilhorst
> <patrickhilhorst97@gmail.com> wrote:
> > alias cpp_check="clang-tidy
> > -checks=\"-*,cppcoreguidelines-*,clang-analyzer-*,misc-*,modernize-*,performance-*,readability-*"
>
> % cpp_check  zle_tricky.c:658: BUG: 0 <= wb (-86) <= zlemetacs (9) <=
> we (9) is not true!
> BUG: substring ends in the middle of a metachar in ztrsub()
>
> Seems to be because wb is computed with the alias
> expanded, but then the alias is unwound before trying to update the
> command line.

Yes, it's the setting of wordbeg in gettok() which makes it a large
number, presumably from the aliased version, whereas when wordebg is
assigned back as difference against zlemetall, the corresponding line
length, that'ss short because it isn't.  So wb is off the start of the
string and mayhem results.

I wonder if the answer to this particular question is as simple as the
following?  This same test is used elswhere in lex.c.

I'm not that worried about making this completion completely sane, more
about fixing the crash and associated index problems.

pws

diff --git a/Src/lex.c b/Src/lex.c
index 6b20e14..e0935bf 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -613,7 +613,7 @@ gettok(void)
     if (lexstop)
 	return (errflag) ? LEXERR : ENDINPUT;
     isfirstln = 0;
-    if ((lexflags & LEXFLAGS_ZLE))
+    if ((lexflags & LEXFLAGS_ZLE) && !(inbufflags & INP_ALIAS))
 	wordbeg = inbufct - (qbang && c == bangchar);
     hwbegin(-1-(qbang && c == bangchar));
     /* word includes the last character read and possibly \ before ! */


  reply	other threads:[~2016-09-05 20:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05 10:42 Patrick Hilhorst
2016-09-05 17:18 ` Bart Schaefer
2016-09-05 20:27   ` Peter Stephenson [this message]
2016-09-06  4:58     ` Bart Schaefer

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=20160905212724.1d05ed9e@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=patrickhilhorst97@gmail.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).