emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Whether a struct window *w is a live/valid window.


From: Keith David Bershatsky
Subject: Whether a struct window *w is a live/valid window.
Date: Wed, 20 Mar 2019 13:14:13 -0700

I am working on feature requests #22873 (multiple fake cursors) and crosshairs 
#17684 (crosshairs that track the cursor position).

In trying to resolve an issue where removal of vertical scroll bars erased fake 
cursors that were laid during update_window, I added a check to see whether the 
window still exists.  Emacs crashed while running under gdb with the following 
backtrace:

(gdb) bt
#0  terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:359
#1  0x00000001001ee93a in die (
    msg=0x100337658 "((((struct vectorlike_header *) ((void *) (gl_intptr_t) 
(((window).i) - (Lisp_Vectorlike)))) ->size) & (PSEUDOVECTOR_FLAG | 
PVEC_TYPE_MASK)) == (PSEUDOVECTOR_FLAG | (PVEC_WINDOW << 
PSEUDOVECTOR_AREA_B"..., 
    file=0x10036c3e8 <__func__.21885+38033> "nsterm.m", line=5325)
    at alloc.c:7214
#2  0x00000001002d8d49 in ns_judge_scroll_bars (f=0x118b5f040) at nsterm.m:5325
#3  0x0000000100071a86 in redisplay_internal (from_where=3) at xdisp.c:19142
#4  * * *

Here is what I did to create the problem:

.  nsterm.h defines the structure for the EmacsScroller and one of the 
components is:  struct window *window

.  I set up a simple function in nsterm.m that returns WINDOW from the 
above-described structure:

    - (struct window *)mc_get_window
    {
      return window;
    }

.  I added a reference in nsterm.h to the new function, at the same location 
under EmacsScroller where other similar functions are referenced (e.g., 
initFrame, setFrame, setPosition, etc.).

    - (struct window *)mc_get_window;

.  In ns_judge_scroll_bars in nsterm.m, I added a check to see whether the 
window was still live/valid:

    for (i = [subviews count]-1; i >= 0; --i)
    {
      view = [subviews objectAtIndex: i];
      if (![view isKindOfClass: [EmacsScroller class]]) continue;
      Lisp_Object window;
      struct window *w = [view mc_get_window];
      if (w != NULL)
        XSETWINDOW (window, w);
      if (w != NULL
          && !WINDOW_LIVE_P (window))
        {
          ...
        }
        ...
    }

.  Emacs is crashing sometimes at the location of XSETWINDOW (window, w) in the 
above-described check.


Q:  What is the proper way to check whether the WINDOW component in 
EmacsScroller coincides with a live/valid window?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]