Subject: bug#21200: closed (Re: bug#21200: 25.0.50; xdisp.c: infinite loop when using invisibility specs)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 07 Aug 2015 13:47:02 +0000

Your bug report

#21200: 25.0.50; xdisp.c: infinite loop when using invisibility specs

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
21200: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21200
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#21200: 25.0.50; xdisp.c: infinite loop when using invisibility specs
From: Eli Zaretskii <[email-masked]>
To: Pip Cet <[email-masked]>
Cc: [email-masked]
Date: Fri, 07 Aug 2015 16:46:27 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Thu, 6 Aug 2015 21:16:26 +0000
> From: Pip Cet <[email-masked]>
> Cc: [email-masked]
> 
> thank you for responding. I've attached the output of M-x
> report-emacs-bug, including the gdb backtrace and a test script that
> triggers the problem. If you need me to run further tests, please let
> me know.

Thanks.  Your analysis was correct, of course.  I fixed the bug with a
slightly different change (see commit 701484d on master), and also
added to the display engine's test suite a test case like the one you
presented.

> My apologies for sending an incomplete report at first.

No need to apologize.

Subject: 25.0.50; xdisp.c: infinite loop when using invisibility specs
From: Pip Cet <[email-masked]>
To: [email-masked]
Date: Thu, 6 Aug 2015 18:26:05 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,
with the current git tree (revision 0aec2aac), I'm running into
problems with an infinite loop in xdisp.c which I believe to be fixed
by this patch, which is reasonably obvious:

diff --git a/src/xdisp.c b/src/xdisp.c
index e45cb87..7b221d4 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -4221,6 +4221,8 @@ handle_invisible_prop (struct it *it)
           if (invis == 2)
             display_ellipsis_p = true;
         }
+
+              charpos = end_charpos;
         }
       while (invis != 0 && endpos < len);

in this loop:

      do
        {
          end_charpos = Fnext_single_property_change (charpos, Qinvisible,
                              it->string, limit);
          if (INTEGERP (end_charpos))
        {
          endpos = XFASTINT (end_charpos);
          charpos = end_charpos;
          prop = Fget_text_property (end_charpos, Qinvisible, it->string);
          invis = TEXT_PROP_MEANS_INVISIBLE (prop);
          if (invis == 2)
            display_ellipsis_p = true;
        }
        }
      while (invis != 0 && endpos < len);

Without the patch, we keep calling Fnext_property_change with the same
arguments and expecting a different result, which obviously never
happens. In fact it seems to me we only need one of charpos and
end_charpos as the code currently stands, anyway. However, charpos =
f(..., charpos, ...) might cause confusion.

I can provide more detail if necessary, but as I said, it's a fairly
obvious bug.
diff --git a/src/xdisp.c b/src/xdisp.c
index e45cb87..7b221d4 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -4221,6 +4221,8 @@ handle_invisible_prop (struct it *it)
 		  if (invis == 2)
 		    display_ellipsis_p = true;
 		}
+
+              charpos = end_charpos;
 	    }
 	  while (invis != 0 && endpos < len);