Subject: Re: 30.0.50; cmcheckmagic aborts when tty_write_glyphs writes "Garbage collecting..." in some cases

From: Eli Zaretskii <[email-masked]>
Date: Thu, 06 Jun 2024 10:55:36 +0300

> From: Daniel Clemente <[email-masked]>
> Date: Wed, 5 Jun 2024 13:51:43 +0000
> Cc: [email-masked]
> 
> > > I also saw a new type of TTY+GC error (not sure if it's the same issue
> > > as this bug):
> > >
> > > alloc.c:7517: Emacs fatal error: assertion failed: t->name != NULL
> > >
> > > Breakpoint 1, terminate_due_to_signal (sig=6,
> > > backtrace_limit=2147483647) at emacs.c:443
> > > 443      signal (sig, SIG_DFL);
> > > (gdb) bt
> > > #0  terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:443
> > > #1  0x000055555573591a in die (msg=0x55555586f838 "t->name != NULL",
> > > file=0x55555586e97e "alloc.c", line=7517) at alloc.c:8082
> > > #2  0x00005555557346e8 in mark_terminals () at alloc.c:7517
> >
> > If this was while you only resized the terminal, how come a terminal
> > was deleted?  Any idea what would cause this?
> 
> I assume that it's t->name == NULL what tells you that a terminal was deleted.

Yes.

> But apparently this terminal wasn't fully deleted, because it's in the
> terminal_list.  If delete_terminal had run, shouldn't it have removed
> it from the list?

It should have, yes.

> So I don't know what happened. reference_count is still 1.

What's more important, kboard, keyboard_coding, and terminal_coding
are not NULL.  Which means delete_terminal_internal was never run for
this terminal.  I don't understand how that could happen, given the
backtrace you show.

I found some unsafe code in delete_terminal and installed a fix.  I
cannot explain how that code could have caused the assertion violation
inside mark_terminals, but maybe it did.