Subject: bug#38031: 26.3; Trying to invoke the macOS File Open window causes Emacs to crash on macOS Catalina

From: Alan Third <[email-masked]>
Date: Sun, 3 Nov 2019 20:39:46 +0000

On Sat, Nov 02, 2019 at 06:19:27AM -0400, Michael Dixon wrote:
> 
> On macOS Catalina, if I attempt to open a file using
>   * File > Open
>   * The toolbar button
>   * "Open a File" on the splash screen
> 
> Emacs crashes. I am using the Homebrew formula with GUI. I have tried
> with other Mac Emacs distributions, such as GNU Emacs for Mac OS X and
> the Homebrew emacs-plus formula with the same result.
> 
> Here's the part of the macOS crash report that I think is useful:
> 
> Application Specific Information:
> *** Terminating app due to uncaught exception 'NSObjectNotAvailableException',
> reason: 'EmacsSavePanel is not a supported subclass for sandboxing'
> abort() called
> terminating with uncaught exception of type NSException

That sounds suspiciously like the fact we’ve subclassed the save panel
class means it’s no longer considered ‘safe’ by Cocoa.

I suspect there’s no immediate work‐around other than trying to work
out what about EmacsSavePanel is problematic.

Can you try applying the patch below? I don’t think it’ll fix
anything, but it should at least rule out that it’s something in these
functions that’s causing this.

modified   src/nsfns.m
@@ -3067,25 +3067,25 @@ The position is returned as a cons cell (X . Y) of the
 }
 
 @implementation EmacsSavePanel
-- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
-{
-  BOOL ret = handlePanelKeys (self, theEvent);
-  if (! ret)
-    ret = [super performKeyEquivalent:theEvent];
-  return ret;
-}
+// - (BOOL)performKeyEquivalent:(NSEvent *)theEvent
+// {
+//   BOOL ret = handlePanelKeys (self, theEvent);
+//   if (! ret)
+//     ret = [super performKeyEquivalent:theEvent];
+//   return ret;
+// }
 @end

 @implementation EmacsOpenPanel
-- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
-{
-  // NSOpenPanel inherits NSSavePanel, so passing self is OK.
-  BOOL ret = handlePanelKeys (self, theEvent);
-  if (! ret)
-    ret = [super performKeyEquivalent:theEvent];
-  return ret;
-}
+// - (BOOL)performKeyEquivalent:(NSEvent *)theEvent
+// {
+//   // NSOpenPanel inherits NSSavePanel, so passing self is OK.
+//   BOOL ret = handlePanelKeys (self, theEvent);
+//   if (! ret)
+//     ret = [super performKeyEquivalent:theEvent];
+//   return ret;
+// }
 @end

-- 
Alan Third