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

Fix crash in Mac extensions #1466

Merged
merged 1 commit into from
Feb 6, 2021
Merged

Fix crash in Mac extensions #1466

merged 1 commit into from
Feb 6, 2021

Conversation

zacwest
Copy link
Member

@zacwest zacwest commented Feb 6, 2021

Summary

Accessing the NSStatusBar in an extension causes a crash; this avoids calling it in extensions. We also should not be touching the status bar in an extension either way.

Any other notes

Didn't show up during the betas, nor does it show up in Sentry. I'm guessing it's crashing so early in the MacBridge code that it doesn't have an opportunity to deal with crash logs.

Crashes look like:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
Assertion failed: (CGAtomicGet(&is_initialized)), function CGSConnectionByID, file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/SkyLight/SkyLight-570.7/SkyLight/Services/Connection/CGSConnection.mm, line 133.
 

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff20504462 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff20532610 pthread_kill + 263
2   libsystem_c.dylib             	0x00007fff20485720 abort + 120
3   libsystem_c.dylib             	0x00007fff204849d6 __assert_rtn + 314
4   com.apple.SkyLight            	0x00007fff24dad771 CGSConnectionByID + 423
5   com.apple.SkyLight            	0x00007fff24f9f58a SLSRegisterConnectionNotifyProc + 31
6   com.apple.AppKit              	0x00007fff236a476c +[NSCGSStatusItem addNavigationChangedNotificationHandler:] + 121
7   com.apple.AppKit              	0x00007fff230fe170 -[NSStatusBar init] + 202
8   com.apple.Foundation          	0x00007fff2136104c _NSFaultInObject + 27
9   io.robbie.HomeAssistant.dev.MacBridge	0x0000000107090389 MacBridgeStatusItem.init() + 105 (MacBridgeStatusItem.swift:4)
10  io.robbie.HomeAssistant.dev.MacBridge	0x0000000107090973 @objc MacBridgeStatusItem.init() + 19
11  io.robbie.HomeAssistant.dev.MacBridge	0x000000010709031b MacBridgeStatusItem.__allocating_init() + 27
12  io.robbie.HomeAssistant.dev.MacBridge	0x000000010709a295 MacBridgeImpl.init() + 213 (MacBridgeImpl.swift:12)
13  io.robbie.HomeAssistant.dev.MacBridge	0x000000010709a383 @objc MacBridgeImpl.init() + 19
14  io.robbie.HomeAssistant.dev.Shared	0x00000001037be6d9 closure #1 in variable initialization expression of Environment.macBridge + 2073 (Environment.swift:141)
15  io.robbie.HomeAssistant.dev.Shared	0x00000001037b9ad6 Environment.init() + 2150 (Environment.swift:132)

@zacwest zacwest enabled auto-merge (squash) February 6, 2021 18:57
@codecov
Copy link

codecov bot commented Feb 6, 2021

Codecov Report

Merging #1466 (2be99b0) into master (52c0be4) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1466   +/-   ##
=======================================
  Coverage   25.10%   25.10%           
=======================================
  Files         206      206           
  Lines       16948    16948           
=======================================
  Hits         4254     4254           
  Misses      12694    12694           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 52c0be4...2be99b0. Read the comment docs.

@zacwest zacwest merged commit 85ccc97 into master Feb 6, 2021
@zacwest zacwest deleted the mac-widgets branch February 6, 2021 19:01
zacwest added a commit that referenced this pull request Feb 6, 2021
## Summary
Accessing the NSStatusBar in an extension causes a crash; this avoids calling it in extensions. We also should not be touching the status bar in an extension either way.

## Any other notes
Didn't show up during the betas, nor does it show up in Sentry. I'm guessing it's crashing so early in the MacBridge code that it doesn't have an opportunity to deal with crash logs.

Crashes look like:

```
Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
Assertion failed: (CGAtomicGet(&is_initialized)), function CGSConnectionByID, file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/SkyLight/SkyLight-570.7/SkyLight/Services/Connection/CGSConnection.mm, line 133.
 

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff20504462 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff20532610 pthread_kill + 263
2   libsystem_c.dylib             	0x00007fff20485720 abort + 120
3   libsystem_c.dylib             	0x00007fff204849d6 __assert_rtn + 314
4   com.apple.SkyLight            	0x00007fff24dad771 CGSConnectionByID + 423
5   com.apple.SkyLight            	0x00007fff24f9f58a SLSRegisterConnectionNotifyProc + 31
6   com.apple.AppKit              	0x00007fff236a476c +[NSCGSStatusItem addNavigationChangedNotificationHandler:] + 121
7   com.apple.AppKit              	0x00007fff230fe170 -[NSStatusBar init] + 202
8   com.apple.Foundation          	0x00007fff2136104c _NSFaultInObject + 27
9   io.robbie.HomeAssistant.dev.MacBridge	0x0000000107090389 MacBridgeStatusItem.init() + 105 (MacBridgeStatusItem.swift:4)
10  io.robbie.HomeAssistant.dev.MacBridge	0x0000000107090973 @objc MacBridgeStatusItem.init() + 19
11  io.robbie.HomeAssistant.dev.MacBridge	0x000000010709031b MacBridgeStatusItem.__allocating_init() + 27
12  io.robbie.HomeAssistant.dev.MacBridge	0x000000010709a295 MacBridgeImpl.init() + 213 (MacBridgeImpl.swift:12)
13  io.robbie.HomeAssistant.dev.MacBridge	0x000000010709a383 @objc MacBridgeImpl.init() + 19
14  io.robbie.HomeAssistant.dev.Shared	0x00000001037be6d9 closure #1 in variable initialization expression of Environment.macBridge + 2073 (Environment.swift:141)
15  io.robbie.HomeAssistant.dev.Shared	0x00000001037b9ad6 Environment.init() + 2150 (Environment.swift:132)
```
zacwest added a commit that referenced this pull request Feb 6, 2021
## Summary
Accessing the NSStatusBar in an extension causes a crash; this avoids calling it in extensions. We also should not be touching the status bar in an extension either way.

## Any other notes
Didn't show up during the betas, nor does it show up in Sentry. I'm guessing it's crashing so early in the MacBridge code that it doesn't have an opportunity to deal with crash logs.

Crashes look like:

```
Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
Assertion failed: (CGAtomicGet(&is_initialized)), function CGSConnectionByID, file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/SkyLight/SkyLight-570.7/SkyLight/Services/Connection/CGSConnection.mm, line 133.
 

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff20504462 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff20532610 pthread_kill + 263
2   libsystem_c.dylib             	0x00007fff20485720 abort + 120
3   libsystem_c.dylib             	0x00007fff204849d6 __assert_rtn + 314
4   com.apple.SkyLight            	0x00007fff24dad771 CGSConnectionByID + 423
5   com.apple.SkyLight            	0x00007fff24f9f58a SLSRegisterConnectionNotifyProc + 31
6   com.apple.AppKit              	0x00007fff236a476c +[NSCGSStatusItem addNavigationChangedNotificationHandler:] + 121
7   com.apple.AppKit              	0x00007fff230fe170 -[NSStatusBar init] + 202
8   com.apple.Foundation          	0x00007fff2136104c _NSFaultInObject + 27
9   io.robbie.HomeAssistant.dev.MacBridge	0x0000000107090389 MacBridgeStatusItem.init() + 105 (MacBridgeStatusItem.swift:4)
10  io.robbie.HomeAssistant.dev.MacBridge	0x0000000107090973 @objc MacBridgeStatusItem.init() + 19
11  io.robbie.HomeAssistant.dev.MacBridge	0x000000010709031b MacBridgeStatusItem.__allocating_init() + 27
12  io.robbie.HomeAssistant.dev.MacBridge	0x000000010709a295 MacBridgeImpl.init() + 213 (MacBridgeImpl.swift:12)
13  io.robbie.HomeAssistant.dev.MacBridge	0x000000010709a383 @objc MacBridgeImpl.init() + 19
14  io.robbie.HomeAssistant.dev.Shared	0x00000001037be6d9 closure #1 in variable initialization expression of Environment.macBridge + 2073 (Environment.swift:141)
15  io.robbie.HomeAssistant.dev.Shared	0x00000001037b9ad6 Environment.init() + 2150 (Environment.swift:132)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants