Subject: Re: bug#58857: 28.2; Emacs on macOS seg faults when deleting fullscreen frame

From: Eli Zaretskii <[email-masked]>
Date: Sat, 29 Oct 2022 09:39:17 +0300

> From: Kevin Lin <[email-masked]>
> Date: Fri, 28 Oct 2022 10:59:16 -0700
> 
> Using stock Emacs 28.2 from https://emacsformacosx.com/:

This distribution is done by someone outside of the Emacs project.  I
therefore suggest that you first report the problem to that person.

> 1) $ /Applications/Emacs.app/Contents/MacOS/Emacs -Q
> 
> 2) open a second frame by, e.g., C-X-5-2
> 
> 3) make it fullscreen, e.g., by clicking the green title button
> 
> 4) delete the fullscreened frame by, e.g., C-X-5-0
> 
> I don't know enough about ObjC or NS to isolate the issue in the ObjC source, but the following work-around works for me:
> 
> (defun frame-turn-off-fullscreen (theframe)
>   (if (eq 'fullboth
> 	  (cdr (assq 'fullscreen
> 		     (frame-parameters theframe))))
>       (set-frame-parameter theframe 'fullscreen nil)))
> 
> (if (boundp 'ns-use-native-fullscreen)
>     (add-to-list 'delete-frame-functions 'frame-turn-off-fullscreen))
> 
> I haven't tried this with Emacs in gdb, but do have macOS-generated crash logs I can send along upon request.
> 
> Also, I'm running this on macOS 13 (Ventura), but this has happened to me since macOS 10.13 (High Sierra) with Emacs 27 (possibly even earlier).  Reporting it only now because the work-around above has worked for me and I forgot about it.

In general, we don't expect any Emacs 28 releases, so it would be of
great help to us if you could try Emacs 29 (from the master branch of
the Emacs Git repository) and see if the problem still exists there.
That's assuming the person who prepares these binaries concludes that
the problem is in the upstream code, not related to the particular way
these binaries are built.

Thanks.