zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: compset -q oddities
Date: Tue, 13 Sep 2016 11:21:41 +0100	[thread overview]
Message-ID: <20160913112141.1243fbde@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <160912232853.ZM27002@torch.brasslantern.com>

On Mon, 12 Sep 2016 23:28:53 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> This one --
>    % _g() { compset -q } 
>    % compdef _g g
>    % g $'\'<TAB>
>    compcore.c:1657: expecting 'x' at offset 2 of "'x"> 
> 
> -- seems to be a legit problem with counting bytes when looking for an
> unbalanced $'...'.  I don't think fixing that would change the outcome,
> that is $'\' --> \' (see quoting converted, above).  I'm not confident
> of how to fix it; PWS was last here in workers/22026 (git 34381548).

The missing offset seems to come because we have an input string
(omitting double quotes) " \\'x" even before we do the double quote
processing.  The \\ goes aways with the double quote processing leaving
the ', which seems to be fine.  It looks like it ought to modify tl to
give the length we set to zlemetall later on, since that comes from the
modified tmp (great names), but it doesn't; however, that doesn't seem
to be the problem.

When we run the lexer over this and get an error, it then ignores that
initial " ", and I think that's what's giving the bad offset.  tokstr is
now "'x " except with ' tokenised (that's not a problem here); we make
efforts to deal with the added final " " but not the fact the previous
initial space has (in technical language) gorn.

I don't know where that initial space is coming from.

I don't know if this means the lexerr stuff is therefore too brittle
about characters it found on an unterminated string to be useful and we
should simply give up in some more well-defined way.

It might be sensible instead of using tokstr to take the input string
when we encounter an error, but I presume we'd need to know at least the
start of input for the current iteration of the loop containing
ctxtlex() (we do have mechanisms for copying literal input during lexing
for use with the new-improved $(...) parsing but that's largely
orthogonal to what's happening here, where "largely" means "actually I
don't really know what's going on in terms of hierarchy because it's way
too complicated").

Anyway, I suspect it ought to be possible to do better.  I've seen this
case crash intermittently as we're accessing bad memory --- we could
probably at least fix up accesses off the end of the string after the
DPUTS for safety.

However, I'm not sure we want to fiddle with this before a release which
we really ought to be making imminently as this is just one of a series
of incrementally partially fixed problems in this area

(This whole interface is horribly brittle anyway, of course, but it's
unlikely anyone's going to dare to rewrite it any time soon.)

pws


  reply	other threads:[~2016-09-13 10:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-11  7:30 Daniel Shahaf
2016-09-12  2:14 ` Bart Schaefer
2016-09-12 23:06   ` Daniel Shahaf
2016-09-13  6:28     ` Bart Schaefer
2016-09-13 10:21       ` Peter Stephenson [this message]
2016-09-14 17:56         ` Bart Schaefer
2016-09-15  5:10           ` Daniel Shahaf
2016-09-16  0:40             ` Bart Schaefer
2016-09-16  3:05               ` [PATCH] Etc/BUGS: Remove fixed items, add 'compset -q' item from workers/39306 Daniel Shahaf
2016-09-16  5:00                 ` Bart Schaefer
2016-09-14  3:22       ` compset -q oddities Daniel Shahaf
2016-09-14  5:20         ` Bart Schaefer
2016-09-14  6:12           ` Daniel Shahaf
2016-09-14 14:59             ` Bart Schaefer
2016-09-14 19:52               ` Oliver Kiddle
2016-09-15  3:08                 ` Bart Schaefer
2016-09-14  8:31           ` Peter Stephenson
2016-09-14 16:04             ` 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=20160913112141.1243fbde@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.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).