From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.devel Subject: Whether a struct window *w is a live/valid window. Date: Wed, 20 Mar 2019 13:14:13 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="5414"; mail-complaints-to="usenet@blaine.gmane.org" To: Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 20 21:25:04 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h6hln-0001Gu-UW for ged-emacs-devel@m.gmane.org; Wed, 20 Mar 2019 21:25:04 +0100 Original-Received: from localhost ([127.0.0.1]:52692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6hlm-0002ea-RD for ged-emacs-devel@m.gmane.org; Wed, 20 Mar 2019 16:25:02 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6hkV-0002c5-4b for emacs-devel@gnu.org; Wed, 20 Mar 2019 16:23:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6hdJ-0005JX-00 for emacs-devel@gnu.org; Wed, 20 Mar 2019 16:16:23 -0400 Original-Received: from gateway32.websitewelcome.com ([192.185.145.107]:15027) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6hdG-00050d-EU for emacs-devel@gnu.org; Wed, 20 Mar 2019 16:16:15 -0400 Original-Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 9A16997983 for ; Wed, 20 Mar 2019 15:14:14 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id 6hbKhRyFnYTGM6hbKhedbk; Wed, 20 Mar 2019 15:14:14 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=wECKDKDCWEc4KC3bI1thDvDCV1gM7rppgu27QNjAdOg=; b=P9mDpFn2HpkKqTMsaHKU9S5apm DNgmmWkvfgW4257wwjauE6bdwBtvnFIr5ro2A7DH8QdKdj5EOjKf/pQVXu12IJLgMppWCjgtpvYWW Oaj1ZFR4ffrC9yB4NF767sZycQSmd2Kj7wjOBHn134rwTGNSPp8sBDyFyUVae4zQjrPgOEZkhQBXP oRlqtQljtYDWx5ywolnn7WDCCDpYDh34b4XsF4bZa48k2pbscSqHNzHu82jY4KlPGYP1Xp8FKzQHU 100VzAU70AZ57+HkKoErzY2ccTWGwiV5K1A4XT7BDJxLiVxr37hO27inlfuFO/Wk7RFrfn3TCdSGC Z4JxLxhQ==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:52382 helo=server.local) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.91) (envelope-from ) id 1h6hbJ-0044rA-T3 for emacs-devel@gnu.org; Wed, 20 Mar 2019 15:14:14 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Source-L: No X-Exim-ID: 1h6hbJ-0044rA-T3 X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.local) [45.48.239.195]:52382 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 192.185.145.107 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:234422 Archived-At: 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?