From: Keith David Bershatsky <esq@lawlist.com>
To: Emacs Devel <emacs-devel@gnu.org>
Subject: Whether a struct window *w is a live/valid window.
Date: Wed, 20 Mar 2019 13:14:13 -0700 [thread overview]
Message-ID: <m2tvfxwbfu.wl%esq@lawlist.com> (raw)
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?
next reply other threads:[~2019-03-20 20:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-20 20:14 Keith David Bershatsky [this message]
2019-03-22 15:01 ` Whether a struct window *w is a live/valid window Alan Third
-- strict thread matches above, loose matches on Subject: below --
2019-03-23 6:30 Keith David Bershatsky
2019-03-23 10:49 ` Alan Third
2019-03-23 17:03 Keith David Bershatsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2tvfxwbfu.wl%esq@lawlist.com \
--to=esq@lawlist.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.