Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAS build crashes with "unable to get application ASN from launchservicesd ..." #16919

Closed
miniak opened this issue Feb 13, 2019 · 9 comments
Closed

Comments

@miniak
Copy link
Contributor

miniak commented Feb 13, 2019

  • Electron Version (output of node_modules/.bin/electron --version):
    • 5.0.0-beta.2
  • Operating System (Platform and Version):
    • macOS 10.13.6
  • Last known working Electron version (if applicable):
    • 4.0.4

Expected Behavior

Adding <input type="checkbox" /> to the DOM in a sandboxed renderer process should work.
Note: app.enableMixedSandboxed() needs to be called in Electron 4.0 and older.

Actual behavior

The renderer process crashes.

To Reproduce

Screenshots

Electron 5.0
screen shot 2019-02-13 at 1 03 08 am
Electron 4.0
screen shot 2019-02-13 at 1 03 47 am

Additional Information

Application Specific Information:
abort() called
rdar://problem/28724618 Couldn't create connection object
_RegisterApplication(), unable to get application ASN from launchservicesd, and this application requires an ASN, so aborting.  error=#-1.
 

Thread 0 Crashed:: CrRendererMain  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff5efb4b66 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff5f17f080 pthread_kill + 333
2   libsystem_c.dylib             	0x00007fff5ef1024d __abort + 144
3   libsystem_c.dylib             	0x00007fff5ef101bd abort + 142
4   com.apple.HIServices          	0x00007fff3578f60a _RegisterApplication + 7911
5   com.apple.HIServices          	0x00007fff3578d64c GetCurrentProcess + 24
6   com.apple.HIToolbox           	0x00007fff361ed4ab MenuBarInstance::GetAggregateUIMode(unsigned int*, unsigned int*) + 63
7   com.apple.AppKit              	0x00007fff34eb5627 _NSScreenConfigurationUpdateSharedInfoForReason + 1546
8   com.apple.AppKit              	0x00007fff34eb4fc9 ___NSScreenConfigurationEnsureInitialUpdateOccurred_block_invoke + 137
9   libdispatch.dylib             	0x00007fff5ee2adb8 _dispatch_client_callout + 8
10  libdispatch.dylib             	0x00007fff5ee2ad6b dispatch_once_f + 41
11  com.apple.AppKit              	0x00007fff34eb4f3e +[_NSScreenConfiguration latestGreatestBackingScaleFactor] + 128
12  com.apple.AppKit              	0x00007fff3450fd83 -[NSView _transformToBackingUsingIntegralizationSpace:] + 242
13  com.apple.AppKit              	0x00007fff3454a063 -[NSView _primitiveConvertSizeToBacking:useIntegralizationSpace:] + 63
14  com.apple.AppKit              	0x00007fff3455535b NSCellImageRectWithSize_centeredInRect_scaling_flipped + 56
15  com.apple.AppKit              	0x00007fff34568ec4 -[NSButtonCell(NSButtonCellPrivate) _imageRectWithRect:] + 244
16  com.apple.AppKit              	0x00007fff34940407 -[NSButtonCell _imageRect:titleRect:forBounds:] + 275
17  com.apple.AppKit              	0x00007fff3458fa4f -[NSButtonCell imageRectForBounds:] + 114
18  com.apple.AppKit              	0x00007fff34619436 -[NSButtonCell drawInteriorWithFrame:inView:] + 1627
19  com.apple.AppKit              	0x00007fff346184fc -[NSButtonCell drawWithFrame:inView:] + 481
20  libblink_core.dylib           	0x00000001544e56f7 blink::ThemePainterMac::PaintCheckbox(blink::Node const*, blink::Document const&, blink::ComputedStyle const&, blink::PaintInfo const&, blink::IntRect const&) + 1399 (theme_painter_mac.mm:652)
...
@welcome
Copy link

welcome bot commented Feb 13, 2019

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@miniak
Copy link
Contributor Author

miniak commented Feb 13, 2019

this seems to be the problem

diff --git a/content/renderer/renderer_main_platform_delegate_mac.mm b/content/renderer/renderer_main_platform_delegate_mac.mm
index b7142c2871faf4a0ba8be79266e9515d81585bdd..3d80c332e9af280a166612f6be54b6f767d729a1 100644
--- a/content/renderer/renderer_main_platform_delegate_mac.mm
+++ b/content/renderer/renderer_main_platform_delegate_mac.mm
@@ -23,9 +23,11 @@
 #include "sandbox/mac/system_services.h"
 #include "services/service_manager/sandbox/mac/sandbox_mac.h"
 
+#ifndef MAS_BUILD
 extern "C" {
 CGError CGSSetDenyWindowServerConnections(bool);
 };
+#endif
 
 namespace content {
 
@@ -35,6 +37,7 @@ namespace {
 // verifies there are no existing open connections), and then indicates that
 // Chrome should continue execution without access to launchservicesd.
 void DisableSystemServices() {
+#ifndef MAS_BUILD
   // Tell the WindowServer that we don't want to make any future connections.
   // This will return Success as long as there are no open connections, which
   // is what we want.
@@ -42,6 +45,7 @@ void DisableSystemServices() {
   CHECK_EQ(result, kCGErrorSuccess);
 
   sandbox::DisableLaunchServices();
+#endif
 }

because

void DisableLaunchServices() {
  // Allow the process to continue without a LaunchServices ASN. The
  // INIT_Process function in HIServices will abort if it cannot connect to
  // launchservicesd to get an ASN. By setting this flag, HIServices skips
  // that.
  OSStatus status = SetApplicationIsDaemon(true);
  OSSTATUS_LOG_IF(ERROR, status != noErr, status) << "SetApplicationIsDaemon";

  // Close any connections to launchservicesd and use an always-false predicate
  // to discourage future attempts to connect.
  _LSSetApplicationLaunchServicesServerConnectionStatus(
      0, ^bool(CFDictionaryRef options) {
        return false;
      });
}

@miniak
Copy link
Contributor Author

miniak commented Feb 13, 2019

SeatbeltExecServer::InitializeSandbox is being used to initialize the renderer process sandbox

@miniak
Copy link
Contributor Author

miniak commented Feb 13, 2019

seems like there are 2 solutions:

  • keep sandbox::DisableLaunchServices(); in the MAS build (not sure if the SetApplicationIsDaemon / _LSSetApplicationLaunchServicesServerConnectionStatus APIs are considered private to cause AppStore rejections)
  • allow access to launchservicesd by the sandboxing profile

@nornagon
Copy link
Member

The sandbox should not be engaged in the MAS build, because MAS apps are already sandboxed (& mostly, the sandboxing APIs Chrome uses don't work under the MAS sandbox).

@miniak
Copy link
Contributor Author

miniak commented Feb 13, 2019

seems like the "mixed sandbox mode" should only be automatically enabled in non-MAS builds then?

@nornagon
Copy link
Member

nornagon commented Feb 13, 2019 via email

@miniak
Copy link
Contributor Author

miniak commented Feb 13, 2019

Related to #15647

@sofianguy sofianguy added this to Unsorted Issues in 5.0.x Feb 13, 2019
@sofianguy sofianguy moved this from Unsorted Issues to Blocks Stable in 5.0.x Feb 14, 2019
@sofianguy sofianguy moved this from Blocks Stable to Fixed for Next Release in 5.0.x Feb 18, 2019
@sofianguy sofianguy moved this from Fixed for Next Release to 5.0.0-beta.3 in 5.0.x Feb 18, 2019
@jthomas-dd
Copy link

jthomas-dd commented Dec 14, 2022

We are getting crashes with the same above error, with a similar stack trace after updating electron from 18.3.6 to 21.2.0

We are not making a mas build, only a mac build.

Thread 14819755 Crashed:
0   libsystem_kernel.dylib          0x18718ad98         <unknown>
1   libsystem_c.dylib               0x1870fa33c         abort
2   HIServices                      0x18ce5f4c0         _RegisterApplication
3   HIServices                      0x18ce5c450         GetCurrentProcess
4   HIToolbox                       0x18fe9fa20         MenuBarInstance::GetAggregateUIMode
5   HIToolbox                       0x18fe9f98c         MenuBarInstance::IsVisible
6   AppKit                          0x189db8698         <unknown>
7   AppKit                          0x189db6340         <unknown>
8   AppKit                          0x189db5f48         <unknown>
9   Electron Framework              0x10d1b683c         base::MessagePumpMac::Create (message_pump_mac.mm:1000)
10  Electron Framework              0x10d18062c         base::SingleThreadTaskExecutor::SingleThreadTaskExecutor (single_thread_task_executor.cc:16)
11  Electron Framework              0x10cbf7798         content::UtilityMain (utility_main.cc:119)
12  Electron Framework              0x10ab5d7cc         content::RunOtherNamedProcessTypeMain
13  Electron Framework              0x10ab5e188         content::ContentMainRunnerImpl::Run
14  Electron Framework              0x10ab5cca0         content::RunContentProcess (content_main.cc:437)
15  Electron Framework              0x10ab5d158         content::ContentMain (content_main.cc:465)
16  Electron Framework              0x10a8d5b2c         ElectronMain (electron_library_main.mm:26)
17  CoScreen Helper (Plugin)        0x1026609a0         <unknown>
18  dyld                            0x1028e508c         <unknown>
19  dyld                            0x1028e5154         <unknown>
20  dyld                            0x1028e510c         <unknown>
21  dyld                            0x1028e50f8         <unknown>
22  dyld                            0x1028e5104         <unknown>

Also with these annotations:

Hiservices

[_RegisterApplication(), unable to get application ASN from launchservicesd, and this application requires an ASN, so aborting.  error=#-1. ]
--

And Launchservices:

[rdar://problem/28724618 Couldn't create connection object <rdar://problem/28724618> Application unable to connect to launchservicesd for an unknown reason (received XPC_ERROR_CONNECTION_INVALID). XPC_ERROR_CONNECTION_INVALID from launchservice]
--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
5.0.x
Fixed in 5.0.0-beta.3
Development

No branches or pull requests

4 participants