From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: [BUG] SIGSEGV under certain circumstances
Date: Sun, 5 Mar 2017 13:45:13 -0800 [thread overview]
Message-ID: <170305134513.ZM26364@torch.brasslantern.com> (raw)
In-Reply-To: <5096E600-D76C-4F71-BE93-C46F256BA7D7@ntlworld.com>
On Mar 5, 6:52pm, Peter Stephenson wrote:
}
} It needs at least to be able to do trivial matching,
} character for character, or it becomes unusable.
Point taken, though arguably it's *already* unusable if it crashes.
Let's go back to the history angle ... from Yen's original message:
} Chinese characters map to:
}
} e7aa81 e784b6 e5a5bd e683b3 e4bda0
}
} in utf-8 (15 bytes, 3 bytes for each character). However, in
} ~/.zsh_history, the saved content is: (I reformatted it for easier
} comparision with the correct version)
}
} e7aa81 e783a4b6 e5a5bd e683a3b3 e4bd8380
Adding brackets to show metafied bytes:
e7aa81 e7[83a4]b6 e5a5bd e6[83a3]b3 e4bd[8380]
That is the same string that is passed to cfp_matcher_pats() according to
the backtrace. So history is reading/writing correctly, it appears.
However, note that it's not the first byte of the three in any of these
examples that is metafied, and if we look at compmatch.c:pattern_match()
we find this:
/*
* Now the line character.
*/
#ifdef MULTIBYTE_SUPPORT
len = mb_metacharlenconv_r(s, &c, &lstate);
#else
/* We have the character itself. */
if (*s == Meta) {
c = STOUC(s[1]) ^ 32;
len = 2;
} else {
c = STOUC(*s);
len = 1;
}
#endif
This will fail in this case, I would think? We have to unmetafy first,
possibly several bytes ahead, and THEN attempt multibyte conversion;
not do either one or the other?
So we're likely to get a false hit on pattern_match(), and in fact the
bad dereference is of *mp in the branch where pattern_match() succeeds.
[Somebody will have to explain to me why (mp += cl) makes sense, as that
seems to be using a byte count to increment a (Cmatcher*), but it's done
in several places.]
Am I going astray here?
next prev parent reply other threads:[~2017-03-05 21:45 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
2017-03-05 18:42 ` Bart Schaefer
2017-03-05 18:52 ` Peter Stephenson
2017-03-05 21:45 ` Bart Schaefer [this message]
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=170305134513.ZM26364@torch.brasslantern.com \
--to=schaefer@brasslantern.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).