1 Reply
      Latest reply on Nov 5, 2019 4:18 AM by mpl
      mpl Level 1 Level 1 (0 points)

        In macOS 10.15 (GA version) I found, that [NSWorkspace openFile:] hangs if called for an app that is unsigned and not verified.

        When this happens, an alert window is displayed with information like this:

         

        ‘“AppName” cannot be opened because the developer cannot be verified’

         

        The dialog has two buttons: “Move to Trash” and “Cancel”.

        When clicking “Cancel”, the dialog disappears but [NSWorkspace openFile:] is still running blocking the main thread for ever.

         

        When sampling the stack, I see the following:

         

        Call graph:

            2725 Thread_600441   DispatchQueue_1: com.apple.main-thread  (serial)

            + 2725 start  (in libdyld.dylib) + 1  [0x7fff7225b405]

            +   2725 main  (in WorkspaceOpenTest2) + 47  [0x1000011af]  main.m:15

            +     2725 NSApplicationMain  (in AppKit) + 777  [0x7fff38169e7d]

            +       2725 -[NSApplication run]  (in AppKit) + 707  [0x7fff38178005]

            +         2725 -[NSApplication(NSEvent) sendEvent:]  (in AppKit) + 352  [0x7fff38188618]

            +           2725 -[NSWindow(NSEventRouting) sendEvent:]  (in AppKit) + 349  [0x7fff382c520d]

            +             2725 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:]  (in AppKit) + 2612  [0x7fff382c5e80]

            +               2725 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:]  (in AppKit) + 4907  [0x7fff383827f9]

            +                 2725 -[NSControl mouseDown:]  (in AppKit) + 748  [0x7fff3848fd39]

            +                   2725 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:]  (in AppKit) + 691  [0x7fff384ba058]

            +                     2725 -[NSCell trackMouse:inRect:ofView:untilMouseUp:]  (in AppKit) + 130  [0x7fff38490aa4]

            +                       2725 NSControlTrackMouse  (in AppKit) + 1745  [0x7fff38823c8c]

            +                         2725 -[NSButtonCell _sendActionFrom:]  (in AppKit) + 96  [0x7fff384ba2ef]

            +                           2725 -[NSCell _sendActionFrom:]  (in AppKit) + 171  [0x7fff3849208c]

            +                             2725 __26-[NSCell _sendActionFrom:]_block_invoke  (in AppKit) + 136  [0x7fff3849218a]

            +                               2725 -[NSControl sendAction:to:]  (in AppKit) + 86  [0x7fff38492258]

            +                                 2725 -[NSApplication(NSResponder) sendAction:to:from:]  (in AppKit) + 299  [0x7fff38432b34]

            +                                   2725 -[AppDelegate runApp:]  (in WorkspaceOpenTest2) + 94  [0x10000125e]  AppDelegate.m:23

            +                                     2725 -[NSWorkspace _openFile:withApplication:andDeactivate:]  (in AppKit) + 386  [0x7fff38a31ad3]

            +                                       2725 LSOpenFromURLSpec  (in LaunchServices) + 298  [0x7fff3c70c345]

            +                                         2725 _LSOpenURLsWithRole_CommonLegacy(__CFArray const*, unsigned int, AEKeyDesc const*, LSApplicationParameters_V1 const*, _LSOpen2Options const*, ProcessSerialNumber*, long, __CFURL const**, unsigned char*)  (in LaunchServices) + 109  [0x7fff3c7de100]

            +                                           2725 _LSOpenURLsWithRole_Common  (in LaunchServices) + 139  [0x7fff3c7dd5c9]

            +                                             2725 _LSOpenStuff  (in LaunchServices) + 1184  [0x7fff3c70c854]

            +                                               2725 _LSOpenStuffCallLocal  (in LaunchServices) + 8155  [0x7fff3c711c9c]

            +                                                 2725 xpc_connection_send_message_with_reply_sync  (in libxpc.dylib) + 238  [0x7fff724a3a1b]

            +                                                   2725 dispatch_mach_send_with_result_and_wait_for_reply  (in libdispatch.dylib) + 50  [0x1003938be]

            +                                                     2725 _dispatch_mach_send_and_wait_for_reply  (in libdispatch.dylib) + 632  [0x10039347e]

            +                                                       2725 mach_msg  (in libsystem_kernel.dylib) + 201  [0x7fff723a4739]

            +                                                         2725 mach_msg_trap  (in libsystem_kernel.dylib) + 10  [0x7fff723a4146]

            2725 Thread_600848: com.apple.NSEventThread

              2725 thread_start  (in libsystem_pthread.dylib) + 15  [0x100402f07]

                2725 _pthread_start  (in libsystem_pthread.dylib) + 125  [0x1004068da]

                  2725 _NSEventThread  (in AppKit) + 132  [0x7fff38186026]

                    2725 CFRunLoopRunSpecific  (in CoreFoundation) + 499  [0x7fff3af5be13]

                      2725 __CFRunLoopRun  (in CoreFoundation) + 1695  [0x7fff3af5c737]

                        2725 __CFRunLoopServiceMachPort  (in CoreFoundation) + 322  [0x7fff3af5d19b]

                          2725 mach_msg  (in libsystem_kernel.dylib) + 60  [0x7fff723a46ac]

                            2725 mach_msg_trap  (in libsystem_kernel.dylib) + 10  [0x7fff723a4146]

         

        This issue can easily be re-produced. Just create a new macOS App project in Xcode, remove ‘Sandbox’ capability from it, add a button and its action method.

        In an implementation of this method, let’s call it runApp, type this:

         

        -(IBAction)runApp:(id)sender {

            [[NSWorkspace sharedWorkspace] openFile:@"/Volumes/TestApp/TestApp.app"];

        }

         

        TestApp.app that I used above can be anything that is not signed and not verified (so that the alert I mentioned above appears). Initially, I found that when trying to run the latest OpenOffice from their dmg.

         

        Now when you run the project, click the button and it will display the alert. Clicking ‘Cancel’ closes the alert but it does NOT make [NSWorkspace openFile:] exit - it will stay in this state forever.