Subject: Re: bug#14970: crash deleting frames

From: Eli Zaretskii <[email-masked]>
Date: Sun, 28 Jul 2013 18:28:25 +0300

> Date: Sun, 28 Jul 2013 10:39:54 +0200
> From: martin rudalics <[email-masked]>
> Cc: [email-masked]
> 
>  > 3216              w = XWINDOW (FRAME_SELECTED_WINDOW (f));
> 
> My crystal ball tells me that Eli will check whether f is a live frame
> in between the following two statements of w32fns.c
> 
> 	  f = x_window_to_frame (dpyinfo, hwnd);
> 	  w = XWINDOW (FRAME_SELECTED_WINDOW (f));

The Force is strong with you.

Yes, I did something similar, although not exactly (you cannot just
use FRAME_LIVE_P here, because it will crash in the same way).

> which should considerably reduce the danger that the frame has been
> recycled when accessing FRAME_SELECTED_WINDOW.

Actually, I think it's recycled between the code that sent
WM_IME_STARTCOMPOSITION to the window and this code (which runs in a
different thread).

> I'm not sure whether it's worth the effort having
> FRAME_SELECTED_WINDOW check that its argument is a live frame.

No, of course not.  We already test the value returned by
x_window_to_frame almost everywhere, so this place should not be
different.