Subject: Re: bug#29548: 25.2; How to DEBUG get-device-terminal

From: Live System User <[email-masked]>
Date: Wed, 14 Feb 2018 12:26:19 -0500

Noam Postavsky <[email-masked]> writes:

> Live System User <[email-masked]> writes:
>
>> Noam Postavsky <[email-masked]> writes:
>>
>>> Hmm, if you can reproduce this semi-regularly, then perhaps the
>>> following patch can catch the reason for the problem.  It sets a
>>> breakpoint in Fsignal while the terminal is in the process of being
>
> I said Fsignal, but posted a patching breaking in signal_or_quit.  The
> latter only exists in emacs-26.  Are you running that or 25.2 as in your
> original report?
>
> Actually I think it might work better to break in longjmp instead.

  Where would I do that?
  
>
>> Thread 1 "emacs" hit Breakpoint 3, begin_delete_terminal () at terminal.c:317
>> 317	    delete_terminal_count++;
>>
>>
>>    I noticed that this didn't end with a paired
>>
>>              "delete_terminal_count--;".
>>              
>>    which it does do so normally.
>
> I believe this means that the problem is indeed a non-local exit
> happening somewhere in there, but we failed to catch it.  Either because
> I posted the Emacs 26 version while you are on Emacs 25, or it doesn't
> go through the signal machinery at all.

  When I first start up Emacs daemon. attach GDB, define commands,
  and then continue:

(gdb) define print_terminal_list
Type commands for definition of "print_terminal_list".
End with a line saying just "end"
>set $t = terminal_list
>while $t
 >print *$t
 >set $t = $t->next_terminal
 >end
>end
(gdb) c
Continuing.

 I see the following immediately upon creating a GUI
 frame via "emacsclient -c":

There is no member named name.

 What does this message mean?
 (Presumably. this is from .gdbinit)

 When I subsequently create a TTY framel I do not
 get this message.
 
 Here is the "terminal list":

(gdb) print_terminal_list
$1 = {
  header = {
    size = 4611686018561777668, 
    gcaligned = 4 '\004'
  }, 
  param_alist = XIL(0), 
  charset_list = XIL(0), 
  Vselection_alist = XIL(0), 
  glyph_code_table = XIL(0), 
  next_terminal = 0x3c63270, 
  id = 6, 
  reference_count = 0, 
  type = output_termcap, 
  name = 0x2b4fc10 "/dev/pts/8", 
  kboard = 0x3dcba00, 
  image_cache = 0x0, 
  display_info = {
    tty = 0x2ea9e00, 
    x = 0x2ea9e00, 
    w32 = 0x2ea9e00, 
    ns = 0x2ea9e00
  }, 
  terminal_coding = 0x2751100, 
---Type <return> to continue, or q <return> to quit---
  keyboard_coding = 0x24c0f00, 
  rif = 0x0, 
  cursor_to_hook = 0x4f8d81 <tty_cursor_to>, 
  raw_cursor_to_hook = 0x4f8e5d <tty_raw_cursor_to>, 
  clear_to_end_hook = 0x4f8f1f <tty_clear_to_end>, 
  clear_frame_hook = 0x4f9022 <tty_clear_frame>, 
  clear_end_of_line_hook = 0x4f9116 <tty_clear_end_of_line>, 
  ins_del_lines_hook = 0x4facda <tty_ins_del_lines>, 
  insert_glyphs_hook = 0x4fa63c <tty_insert_glyphs>, 
  write_glyphs_hook = 0x4f9f77 <tty_write_glyphs>, 
  delete_glyphs_hook = 0x4faae4 <tty_delete_glyphs>, 
  ring_bell_hook = 0x4f8059 <tty_ring_bell>, 
  toggle_invisible_pointer_hook = 0x0, 
  reset_terminal_modes_hook = 0x4f843a <tty_reset_terminal_modes>, 
  set_terminal_modes_hook = 0x4f8254 <tty_set_terminal_modes>, 
  update_begin_hook = 0x0, 
  update_end_hook = 0x4f860f <tty_update_end>, 
  set_terminal_window_hook = 0x4f86b6 <tty_set_terminal_window>, 
  mouse_position_hook = 0x4fe4e2 <term_mouse_position>, 
  frame_rehighlight_hook = 0x0, 
  frame_raise_lower_hook = 0x0, 
  fullscreen_hook = 0x0, 
  menu_show_hook = 0x500c1d <tty_menu_show>, 
---Type <return> to continue, or q <return> to quit---
  popup_dialog_hook = 0x0, 
  set_vertical_scroll_bar_hook = 0x0, 
  set_horizontal_scroll_bar_hook = 0x0, 
  condemn_scroll_bars_hook = 0x0, 
  redeem_scroll_bar_hook = 0x0, 
  judge_scroll_bars_hook = 0x0, 
  read_socket_hook = 0x566c0e <tty_read_avail_input>, 
  frame_up_to_date_hook = 0x0, 
  buffer_flipping_unblocked_hook = 0x0, 
  delete_frame_hook = 0x5017eb <tty_free_frame_resources>, 
  delete_terminal_hook = 0x503230 <delete_tty>
}
$2 = {
  header = {
    size = 4611686018561777668, 
    gcaligned = 4 '\004'
  }, 
  param_alist = XIL(0x398c6d3), 
  charset_list = XIL(0), 
  Vselection_alist = XIL(0), 
  glyph_code_table = XIL(0), 
  next_terminal = 0xd38140, 
  id = 5, 
---Type <return> to continue, or q <return> to quit---
  reference_count = 1, 
  type = output_x_window, 
  name = 0x3452030 ":0", 
  kboard = 0x33f1130, 
  image_cache = 0x2948760, 
  display_info = {
    tty = 0x3665600, 
    x = 0x3665600, 
    w32 = 0x3665600, 
    ns = 0x3665600
  }, 
  terminal_coding = 0x399ea00, 
  keyboard_coding = 0x3711000, 
  rif = 0x92d640 <x_redisplay_interface>, 
  cursor_to_hook = 0x0, 
  raw_cursor_to_hook = 0x0, 
  clear_to_end_hook = 0x0, 
  clear_frame_hook = 0x518b22 <x_clear_frame>, 
  clear_end_of_line_hook = 0x0, 
  ins_del_lines_hook = 0x51938c <x_ins_del_lines>, 
  insert_glyphs_hook = 0x0, 
  write_glyphs_hook = 0x0, 
  delete_glyphs_hook = 0x5189c2 <x_delete_glyphs>, 
---Type <return> to continue, or q <return> to quit---
  ring_bell_hook = 0x519312 <XTring_bell>, 
  toggle_invisible_pointer_hook = 0x5192cc <XTtoggle_invisible_pointer>, 
  reset_terminal_modes_hook = 0x0, 
  set_terminal_modes_hook = 0x0, 
  update_begin_hook = 0x51163b <x_update_begin>, 
  update_end_hook = 0x511eef <x_update_end>, 
  set_terminal_window_hook = 0x0, 
  mouse_position_hook = 0x51ab85 <XTmouse_position>, 
  frame_rehighlight_hook = 0x519fe3 <XTframe_rehighlight>, 
  frame_raise_lower_hook = 0x525056 <XTframe_raise_lower>, 
  fullscreen_hook = 0x523cfb <XTfullscreen_hook>, 
  menu_show_hook = 0x498353 <x_menu_show>, 
  popup_dialog_hook = 0x4994da <xw_popup_dialog>, 
  set_vertical_scroll_bar_hook = 0x51bd30 <XTset_vertical_scroll_bar>, 
  set_horizontal_scroll_bar_hook = 0x51c2c7 <XTset_horizontal_scroll_bar>, 
  condemn_scroll_bars_hook = 0x51ca88 <XTcondemn_scroll_bars>, 
  redeem_scroll_bar_hook = 0x51cb79 <XTredeem_scroll_bar>, 
  judge_scroll_bars_hook = 0x51d085 <XTjudge_scroll_bars>, 
  read_socket_hook = 0x5208f0 <XTread_socket>, 
  frame_up_to_date_hook = 0x511f45 <XTframe_up_to_date>, 
  buffer_flipping_unblocked_hook = 0x512006 <XTbuffer_flipping_unblocked_hook>, 
  delete_frame_hook = 0x526493 <x_destroy_window>, 
---Type <return> to continue, or q <return> to quit---
  delete_terminal_hook = 0x527ec2 <x_delete_terminal>
}
$3 = {
  header = {
    size = 4611686018561777668, 
    gcaligned = 4 '\004'
  }, 
  param_alist = XIL(0x1217ec3), 
  charset_list = XIL(0x1134013), 
  Vselection_alist = XIL(0), 
  glyph_code_table = XIL(0), 
  next_terminal = 0x0, 
  id = 0, 
  reference_count = 1, 
  type = output_initial, 
  name = 0xce6940 "initial_terminal", 
  kboard = 0xd33a00, 
  image_cache = 0x0, 
  display_info = {
    tty = 0x0, 
    x = 0x0, 
    w32 = 0x0, 
    ns = 0x0
---Type <return> to continue, or q <return> to quit---
  }, 
  terminal_coding = 0xd3abe0, 
  keyboard_coding = 0xd3a970, 
  rif = 0x0, 
  cursor_to_hook = 0x0, 
  raw_cursor_to_hook = 0x0, 
  clear_to_end_hook = 0x0, 
  clear_frame_hook = 0x0, 
  clear_end_of_line_hook = 0x0, 
  ins_del_lines_hook = 0x0, 
  insert_glyphs_hook = 0x0, 
  write_glyphs_hook = 0x0, 
  delete_glyphs_hook = 0x0, 
  ring_bell_hook = 0x0, 
  toggle_invisible_pointer_hook = 0x0, 
  reset_terminal_modes_hook = 0x0, 
  set_terminal_modes_hook = 0x0, 
  update_begin_hook = 0x0, 
  update_end_hook = 0x0, 
  set_terminal_window_hook = 0x0, 
  mouse_position_hook = 0x0, 
  frame_rehighlight_hook = 0x0, 
  frame_raise_lower_hook = 0x0, 
---Type <return> to continue, or q <return> to quit---
  fullscreen_hook = 0x0, 
  menu_show_hook = 0x0, 
  popup_dialog_hook = 0x0, 
  set_vertical_scroll_bar_hook = 0x0, 
  set_horizontal_scroll_bar_hook = 0x0, 
  condemn_scroll_bars_hook = 0x0, 
  redeem_scroll_bar_hook = 0x0, 
  judge_scroll_bars_hook = 0x0, 
  read_socket_hook = 0x0, 
  frame_up_to_date_hook = 0x0, 
  buffer_flipping_unblocked_hook = 0x0, 
  delete_frame_hook = 0x5044cf <initial_free_frame_resources>, 
  delete_terminal_hook = 0x50458a <delete_initial_terminal>
}
(gdb) c
Continuing.

Thread 1 "emacs" hit Breakpoint 5, begin_delete_terminal () at terminal.c:317
317	    delete_terminal_count++;

Thread 1 "emacs" hit Breakpoint 6, end_delete_terminal () at terminal.c:321
321	    delete_terminal_count--;

"