Subject: Re: bug#19435: SIGSEGV in PSEUDOVECTOR_TYPEP when using find-file on a RTL filename

From: Dmitry Antipov <[email-masked]>
Date: Wed, 24 Dec 2014 11:36:42 +0300

On 12/24/2014 10:25 AM, Ivan Shmakov wrote:

> 	As of 36c43e95de5e (2014-12-18 16:44:11 +0000), Emacs segfaults
> 	when trying to use find-file on "\u062f\u0646\u06cc" (encoded as
> 	a ASCII-safe Emacs string literal here.)
>
> 	Strangely enough, $ emacs -Q handles that filename just fine.
>
> 	The backtrace is MIMEd.

Reproduced.  This seems to be a redisplay glitch since composition_compute_stop_pos
makes an attempt to move CMP_IT beyond STRING's boundaries, as handled by the
following extra eassert:

diff --git a/src/composite.c b/src/composite.c
index 8982c90..fa60cc0 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1005,7 +1005,10 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos,
        while (charpos < endpos)
         {
           if (STRINGP (string))
-           FETCH_STRING_CHAR_ADVANCE (c, string, charpos, bytepos);
+           {
+             eassert (charpos < SCHARS (string) && bytepos < SBYTES (string));
+             FETCH_STRING_CHAR_ADVANCE (c, string, charpos, bytepos);
+           }
           else
             FETCH_CHAR_ADVANCE (c, charpos, bytepos);
           if (c == '\n')

Dmitry