Subject: bug#74902: 31.0.50; Segfault when deleting frames

From: Steven Allen <[email-masked]>
Date: Fri, 10 Jan 2025 08:19:08 -0800

Robert Pluim <[email-masked]> writes:

>>>>>> On Tue, 31 Dec 2024 08:31:04 -0800, Steven Allen <[email-masked]> said:
>
>     Steven> Eli Zaretskii <[email-masked]> writes:
>     >> Thanks.  I guess we also need a FRAME_LIVE_P test in
>     >> gui_consider_frame_title?
>
>     Steven> I've attached a patch for that but note that it doesn't actually help in
>     Steven> this situation because the frame isn't deleted until:
>
>     Steven> https://git.savannah.gnu.org/cgit/emacs.git/tree/src/frame.c?h=2f1052d9b0de551dc3a463ed54e21c63517497ab#n2536
>
>     Steven> Whereas the crash happens here, 36 lines above:
>
>     Steven> https://git.savannah.gnu.org/cgit/emacs.git/tree/src/frame.c?h=2f1052d9b0de551dc3a463ed54e21c63517497ab#n2500
>
> gui_consider_frame_title looks at Vframe_list, so removing the
> to-be-deleted frame from it should be enough (unless this crash was
> with my patch applied?)

The crash was fixed with your patch. Removing the to-be-deleted frame
from the frame list earlier sounds like the best approach (maintain an
invariant that the frame list will never reference a dead frame) but I
don't know if that'll cause other issues.