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

From: Live System User <[email-masked]>
Date: Sat, 06 Jan 2018 05:16:55 -0500

Noam Postavsky <[email-masked]> writes:

> Live System User <[email-masked]> writes:
>
>>   Here's a new occurrance (see below):
>
> 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
> deleted (requires reproducing the problem under gdb with the patched
> .gdbinit loaded).

   I applied your patch; thanks for it.

   While playing around wirh the emacs daemon and TTY/GUI client frames,
   I got a slightly diffent error message this time  (I'lltry to see if
   I can get back into the same exact situation/error message I got
   before later...but here's this (perhaps?) slightly different one):

    $  emacsclient -t file1.txt
    *ERROR*: Terminal is not live, can’t create new frames on it

   In the *server* buffer, I see:
  
server <127.0.0.1:60208>: Terminal is not live, can’t create new
frames on it
server <127.0.0.1:60208>: Status changed to closed: connection broken
by remote peer
server <127.0.0.1:60208>: server-delete-client
server <127.0.0.1:60208>: Deleted

   (The screen quickly flashed the emacsclient frame and then it
   disappered).

   Your patch output displayed:

Breakpoint 3 at 0x508f7b: file terminal.c, line 317.
Breakpoint 4 at 0x508f91: file terminal.c, line 321.
(gdb) c
Continuing.
[New Thread 0x7fc3a0d25700 (LWP 7745)]
warning: the debug information found in "/usr/lib/debug//lib64/libfreebl3.so.debug" does not match "/lib64/libfreebl3.so" (CRC mismatch).

[New Thread 0x7fc39b162700 (LWP 7746)]

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

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

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

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

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.

   After the initial error, the "delete_terminal_count"  is no longer
   displayed.

   The *Messages* buffer contains multiple:

get-device-terminal: Invalid argument #<terminal 5> in
'get-device-terminal'
Error running timer battery-update-handler' (error Invalid argument
#<terminal 5> in 'get-device-terminal'")

   whenever its timer goes off.

   The "print_terminal_list" output was:

(gdb) print_terminal_list
$1 = {
  header = {
    size = 4611686018561773572
  }, 
  param_alist = 0, 
  charset_list = 0, 
  Vselection_alist = 0, 
  glyph_code_table = 0, 
  next_terminal = 0x0, 
  id = 0, 
  reference_count = 1, 
  type = output_initial, 
  name = 0xcaf940 "initial_terminal", 
  kboard = 0xce1fb0, 
  image_cache = 0x0, 
  display_info = {
    tty = 0x0, 
    x = 0x0, 
    w32 = 0x0, 
    ns = 0x0
  }, 
  terminal_coding = 0xce8d70, 
  keyboard_coding = 0xce8b00, 
---Type <return> to continue, or q <return> to quit---
  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, 
  fullscreen_hook = 0x0, 
  menu_show_hook = 0x0, 
  popup_dialog_hook = 0x0, 
---Type <return> to continue, or q <return> to quit---
  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, 
  delete_frame_hook = 0x509839 <initial_free_frame_resources>, 
  delete_terminal_hook = 0x5098f4 <delete_initial_terminal>
}
(gdb) 

   Thanks.