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: Chi-Hsuan Yen <yan12125@gmail.com>
Subject: Re: [BUG] SIGSEGV under certain circumstances
Date: Sun, 5 Mar 2017 16:17:20 +0000	[thread overview]
Message-ID: <20170305161720.6f3773d6@ntlworld.com> (raw)
In-Reply-To: <170305080054.ZM24832@torch.brasslantern.com>

On Sun, 5 Mar 2017 08:00:54 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> In computil.c:cfp_matcher_pats there is a loop that walks the string
> from the command line, in this case the file name recalled from the
> history, Comparing each character to the matcher pattern.  If it gets
> a match it adjusts some counters that are initialized from strlen() of
> the candidate string, exiting the loop when the counters reach the
> end of the string.  It also adjusts pointers into string, and one of
> those pointers is running past the end.
> 
> The pattern is m:{a-zA-Z}={A-Za-z} m:{a-zA-Z}={A-Za-z} but I don't
> think that matters, it's the candidate string that's causing the
> confusion.
>...
> So there seem to be two problems, one that the history is either not
> saving or not reloading the Chinese characters correctly, and two
> that the loop in cfp_matcher_pats is not counting correctly when it
> examines that garbage string recalled from history.

The matcher code doesn't handle non-ASCII characters, and probably never
wlll --- I spent ages looking at this some years ago until I realised I
was getting nowhere.  The most we can hope is it's safe about pointing
off the end of the string.  That's complicated by the fact that the rest
of completion does handle multibyte characters.

There's a good chance this is another problem with the handling of Meta
characters.  We know that broken history parsing can get these wrong ---
we've had problems like that not so long ago.  If it gets past that
stage, we make assumptions about what the presence of a Meta in the
string means that, if it fails, can lead to any number of problems.  In
particular, we assume that any Meta anywhere in the string has the
standard meaning.

We might be able to debug the second half of this by testing for
incorrect metafication in the matcher code, but I'm not sure how far
that gets us.  We're not going to be able to be safe at every point in
the code.

I suspect tracking down the problem at the input stage is the only good
bet.   You might have thought that would be much more mechanical and
hence easy...

pws


  reply	other threads:[~2017-03-05 16:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-01 15:38 Chi-Hsuan Yen
2017-03-04 23:11 ` Bart Schaefer
2017-03-05 12:55   ` Chi-Hsuan Yen
2017-03-05 13:09   ` Chi-Hsuan Yen
2017-03-05 16:00     ` Bart Schaefer
2017-03-05 16:17       ` Peter Stephenson [this message]
2017-03-05 18:42         ` Bart Schaefer
2017-03-05 18:52           ` Peter Stephenson
2017-03-05 21:45             ` Bart Schaefer
2017-03-05 22:31               ` Bart Schaefer
2017-03-05 22:41               ` Daniel Shahaf
2017-03-05 22:51                 ` Bart Schaefer
2017-03-05 23:07                   ` Bart Schaefer
2017-03-06  0:23                     ` Bart Schaefer
2017-03-06  9:47               ` Peter Stephenson
2017-03-06 17:10                 ` 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=20170305161720.6f3773d6@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=yan12125@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).