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

From: Noam Postavsky <[email-masked]>
Date: Thu, 14 Dec 2017 20:37:19 -0500

Live System User <[email-masked]> writes:

> (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) print_terminal_list
> $1 = {
>   header = {
>     size = 4611686018561773572
>   }, 
>   param_alist = XIL(0x2bfe553), 
>   charset_list = XIL(0x102ec33), 
>   Vselection_alist = XIL(0), 
>   glyph_code_table = XIL(0), 
>   next_terminal = 0x363e3d8, 
>   id = 5, 
>   reference_count = 0, 
>   type = output_termcap, 
>   name = 0x0, 

As far as I can tell, the only place that sets a terminals 'name' field
to NULL is in delete_terminal:

    delete_terminal (struct terminal *terminal)
    {
      ...
      terminal->name = NULL;

      [...]
      *tp = terminal->next_terminal;
      ...

Something must have happened in the [...] to prevent the terminal from
being removed from the terminal list.  There is a lot code in that
[...], with a lot of conditional, recursive calls so it's hard to say
what could be the problem.  One thing I see, is that it calls
Fframe_parameter which uses Fassq which checks for quit signals.  Not
sure how plausible it is that you could have managed to quit just at the
right time though.