Subject: Re: bug#19511: 25.0.50; Failed assertions in redisplay() code. (dispnew.c:1405; xdisp.c:17524)

From: Eli Zaretskii <[email-masked]>
Date: Mon, 05 Jan 2015 17:58:05 +0200

> From: Andreas Matthias <[email-masked]>
> Date: Sun, 04 Jan 2015 23:27:33 +0100
> 
> With the attached example code I can trigger two different assertions
> somewhere down the line of redisplay():
> 
> 1) dispnew.c:1405: Emacs fatal error: assertion failed: row >= 0 && row < matrix->nrows
> 
> 2) xdisp.c:17524: Emacs fatal error: assertion failed: row->enabled_p
> 
> 
> Unfortunately I could not further isolate the elisp code which eventually
> causes these assertions to fail. The following packages from MELPA are
> involved: lua-mode, polymode. (version numbers see example code)

The reason for this is that Polymode does something unthinkable: it
calls bury-buffer in the function it installs as
font-lock-fontify-region-function, which buries the buffer being
fontified, and as side effect switches the buffer displayed in the
window.  When this is called by redisplay, the effect is that the
information about the window end point gets invalidated right from
under the feet of the display engine, in the middle of the code that
tries to use that information for one of redisplay optimizations.

I have now disabled that optimization for packages which commit such
atrocities, so Polymode is now merely a performance killer, not a
crasher.

I hope Polymode will be changed to not call bury-buffer in that
situation (I always thought bury-buffer is strictly for interactive
use, FWIW).

> Note: With a recently checked out Emacs 25.0.50 I can trigger both assertions
> as described below. Concerning Emacs 24.3.1 I can trigger only the first
> assertion but not the second one.

Emacs 24.3 escapes the 2nd assertion by sheer luck, AFAICS, and 24.4
is affected by both.  So I installed the fix for this in the emacs-24
branch (commit d279e66).

Thanks.