unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Kai Ma <justksqsf@gmail.com>
To: 59794@debbugs.gnu.org
Subject: bug#59794: Acknowledgement (29.0.60; NSport segfaults when a fullscreen frame is being closed)
Date: Sat, 03 Dec 2022 18:48:15 +0800	[thread overview]
Message-ID: <m24jucvk40.fsf@gmail.com> (raw)
In-Reply-To: <handler.59794.B.167005568724588.ack@debbugs.gnu.org> (GNU bug Tracking System's message of "Sat, 03 Dec 2022 08:22:02 +0000")

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

I did some investigation, but I was unable to identify the problem on
the Emacs side.

I traced the code, and found that even after [[view window] close] is
called (nsterm.m L1626), [EmacsView resetCursorRects:] can still be
invoked for that window.  To my understanding, such calls are initiated
by AppKit, not in the control of Emacs.

Also, Emacs 27 and Emacs 28 (NS) also suffer from exactly the same issue
(the same invalid access).  I was unable to reproduce it using the Mac
port.  Given the severity of segfaults, I suspect it's very likely due
to upstream Cocoa changes that only cause problems on newer versions of
macOS.

I'm currently using the trivial fix to prevent further data loss:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Prevent a segfault on the NS port --]
[-- Type: text/x-patch, Size: 1115 bytes --]

From 8ea35a8099f34f482d090ea8068e89f52dcd29ac Mon Sep 17 00:00:00 2001
From: Kai Ma <justksqsf@gmail.com>
Date: Sat, 3 Dec 2022 18:17:26 +0800
Subject: [PATCH] Prevent a segfault when deleting a fullscreen frame on
 NextStep.

* nsterm.m ([EmacsView resetCursorRects:]): Be defensive when
accessing FRAME_OUTPUT_DATA.
---
 src/nsterm.m | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index 507f2a9e7d..c09f743ec7 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6703,8 +6703,16 @@ - (BOOL)acceptsFirstResponder
 
 - (void)resetCursorRects
 {
-  NSRect visible = [self visibleRect];
-  NSCursor *currentCursor = FRAME_POINTER_TYPE (emacsframe);
+  NSRect visible;
+  NSCursor *currentCursor;
+
+  /* On macOS 13, [resetCursorRects:] could be called even after the
+     window is closed. */
+  if (! emacsframe || ! FRAME_OUTPUT_DATA (emacsframe))
+    return;
+
+  visible = [self visibleRect];
+  currentCursor = FRAME_POINTER_TYPE (emacsframe);
   NSTRACE ("[EmacsView resetCursorRects]");
 
   if (currentCursor == nil)
-- 
2.37.1 (Apple Git-137.1)


  parent reply	other threads:[~2022-12-03 10:48 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02 12:01 bug#59794: 29.0.60; NSport segfaults when a fullscreen frame is being closed Kai Ma
2022-12-03 10:08 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-03 10:27 ` Eli Zaretskii
2022-12-03 11:44   ` Gerd Möllmann
2022-12-03 13:03     ` Kai Ma
2022-12-03 13:53       ` Gerd Möllmann
2022-12-03 20:51         ` Kai Ma
     [not found] ` <handler.59794.B.167005568724588.ack@debbugs.gnu.org>
2022-12-03 10:48   ` Kai Ma [this message]
2022-12-04  6:54     ` bug#59794: 29.0.60; NSport segfaults when a fullscreen frame is being closed) Eli Zaretskii
2022-12-04  9:10       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-04 10:24         ` Eli Zaretskii
2022-12-04 11:59           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-04 12:21             ` Eli Zaretskii
2022-12-04 12:23               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-04 12:45               ` Kai Ma
2022-12-04 12:53                 ` Eli Zaretskii
2022-12-04 13:53                 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-04 14:04                   ` Kai Ma
2022-12-05  1:10                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-10 20:35 ` Steven E. Harris
2023-01-11  1:14   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-11  4:38     ` Gerd Möllmann
2023-01-17 21:37       ` Steven E. Harris
2023-01-18  5:06         ` Gerd Möllmann

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m24jucvk40.fsf@gmail.com \
    --to=justksqsf@gmail.com \
    --cc=59794@debbugs.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).