Subject: 29.0.60; Crash in format_mode_line_unwind_data
From: Juri Linkov <[email-masked]>
To: [email-masked]
Date: Thu, 15 Dec 2022 19:04:30 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

0. emacs -Q
1. Evaluate:

(add-hook 'kill-buffer-hook
          (lambda ()
            (run-with-timer 0 nil (lambda () (tab-bar-select-tab 1)))))

2. Type:

C-x t 2
C-x k RET

Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
format_mode_line_unwind_data (target_frame=target_frame@entry=0x5555563c3310, obuf=<optimized out>, owin=XIL(0x55555602562d), save_proptrans=save_proptrans@entry=false) at xdisp.c:13223
13223	      current_buffer = b;
(gdb) bt
#0  format_mode_line_unwind_data (target_frame=target_frame@entry=0x5555563c3310, obuf=<optimized out>, owin=XIL(0x55555602562d), save_proptrans=save_proptrans@entry=false) at xdisp.c:13223
#1  0x0000555555600752 in gui_consider_frame_title (frame=XIL(0x5555563c3315)) at xdisp.c:13417
#2  0x0000555555605219 in prepare_menu_bars () at xdisp.c:13544
#3  redisplay_internal () at xdisp.c:16462
#4  0x00005555556ea03a in read_char (commandflag=1, map=XIL(0x555556770ea3), prev_event=XIL(0), used_mouse_menu=0x7fffffffddcb, end_time=0x0) at keyboard.c:2627
#5  0x00005555556ec658 in read_key_sequence (keybuf=<optimized out>, prompt=XIL(0), dont_downcase_last=<optimized out>, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=<optimized out>) at keyboard.c:10074
#6  0x00005555556ee2c0 in command_loop_1 () at lisp.h:1171
#7  0x000055555576a1b7 in internal_condition_case (bfun=bfun@entry=0x5555556ee0e0 <command_loop_1>, handlers=handlers@entry=XIL(0x90), hfun=hfun@entry=0x5555556e11b0 <cmd_error>) at eval.c:1474
#8  0x00005555556d986a in command_loop_2 (handlers=handlers@entry=XIL(0x90)) at keyboard.c:1125
#9  0x000055555576a0f9 in internal_catch (tag=tag@entry=XIL(0xfa80), func=func@entry=0x5555556d9840 <command_loop_2>, arg=arg@entry=XIL(0x90)) at eval.c:1197
#10 0x00005555556d9806 in command_loop () at lisp.h:1171
#11 0x00005555556e0d08 in recursive_edit_1 () at keyboard.c:712
#12 0x00005555556e10b0 in Frecursive_edit () at keyboard.c:795
#13 0x00005555555b1a73 in main (argc=<optimized out>, argv=<optimized out>) at emacs.c:2529

Lisp Backtrace:
"redisplay_internal (C function)" (0x0)
(gdb) l
13218
13219	      /* If we select a window on another frame, make sure that that
13220		 selection does not leave its buffer's point modified when
13221		 unwinding (Bug#32777).  */
13222	      ASET (vector, 10, buffer);
13223	      current_buffer = b;
13224	      ASET (vector, 11, build_marker (current_buffer, PT, PT_BYTE));
13225	      current_buffer = cb;
13226	    }
13227
(gdb) p buffer
$3 = XIL(0)

This means that at this point the value of this is nil:

  XWINDOW (target_frame->selected_window)->contents;