Subject: bug#61514: 30.0.50; sadistically long xml line hangs emacs

From: Stefan Monnier <[email-masked]>
Date: Sun, 19 Feb 2023 18:12:05 -0500

> I'm not surprised.  There's something weird going on there.  Do you
> understand the logic in this snippet near the end of
> re_match_2_internal:

I should understand it, because I think I wrote (or at least
significantly changed) this part (20 years ago, maybe?).

>     /* We goto here if a matching operation fails. */
>     fail:
>       maybe_quit ();
>       if (!FAIL_STACK_EMPTY ())
> 	{
> 	  [...]
> 	}
>       else
> 	break;   /* Matching at this starting point really fails.  */
>     } /* for (;;) */
>
>   if (best_regs_set)
>     goto restore_best_regs;
>
>   unbind_to (count, Qnil);
>   SAFE_FREE ();
>
>   if (max_redisplay_ticks > 0 && nchars > 0)
>     update_redisplay_ticks (nchars / 50 + 1, NULL);
>
>   return -1;				/* Failure to match.  */
>
> What is the mechanism to empty the failure stack, which eventually
> causes us to report a failure?

It's `POP_FAILURE_POINT` done soon after testing `FAIL_STACK_EMPTY`.

> Maybe we should devise some mechanism whereby re_match_2_internal
> forcibly returns a failure after too much bactracking (if that is what
> happens here), when called from redisplay?
>
> Stefan, any ideas?

I don't understand the problem well enough yet, sorry.

        Stefan