bug#81407: 31.0.90; Crash in display_line: stale glyph_row after window-config change from menu-bar :enable eval during redisplay
Aaron Iba <[email protected]> Tue, 4 Aug 2026 10:04:29 -0400
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <CAH_c0bfH+S8ama3zf+Jbqe1W8DboPzqF-8Q=uV9cQ4VtLdEh0Q@mail.gmail.com> |
> Sorry, I don't understand: where do you see code that frees the matrix > and then allocates it, without changing the value of > window_desired_matrix? My earlier message was imprecise, sorry. The old matrix never goes through adjust_glyph_matrix on this path: Fdelete_other_windows_internal calls free_window_matrices (r) on the frame's old root, which frees both matrices of every leaf window under it -- including WINDOW, the window being kept -- and sets them to NULL; then allocate_matrices_for_window_redisplay creates brand-new structs, and only those reach adjust_glyph_matrix. So window_desired_matrix holds a freed address by the time your comparison runs, and it matches only when malloc happens to reuse that address (which is what distinguished my runs where the guard fired from the runs that crashed, and I suspect also why it worked on your machine). This is also why free_glyph_matrix does run on live frames: via free_window_matrices from delete-other-windows, delete-window, and set-window-configuration. Comparing it->w->desired_matrix against the captured pointer after the fontification call returns closes the gap; with that one check added to your patch, the recipe went 8 for 8 without a crash here (about half crashed before). That said, I readily concede this may not be worth more of your time or more complexity in the codebase: hitting it requires Lisp that changes the window configuration from inside redisplay, which took an unlikely conspiracy of three packages in my case and is already fixed at the Lisp level (perspective.el PR #233, merged). For posterity I've put the full details -- annotated control flow, the instrumented traces, the tested add-on patch, and both -Q recipes -- in one place: https://gist.github.com/aiba/4f15747785697af18ed3ee297b61744f Nothing here needs a reply; happy to test if you take it further, and equally content if you decide the current patch is protection enough. Thanks for all your work on this.