insidegui/WWDC

Crash when permissions are weird in the application support directory

insidegui opened this issue · 3 comments

For some reason, a user had their io.wwdc.app folder with weird permissions. We should address these types of issues with some sort of message instead of a fatal error, even though the app can't really continue.

Two things that came to mind:
1 - Offer the option to delete/move the existing folder if this issue occurs
2 - Offer the option to save the database somewhere else

Application Specific Information:
Fatal error: Realm initialization error: Error Domain=io.realm.unknown Code=13 "Permission denied" UserInfo={Category=system, NSLocalizedDescription=Permission denied, Error Code=13}: file /Users/inside/Developer/_projects/WWDC/WWDC/AppCoordinator.swift, line 80

I had the app also crash shortly after launch and removing the mentioned folder in ApplicationSupport fixed it. My error though was

Application Specific Information:
Crashing on exception: Cannot register notification blocks from within write transactions.

Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff32b18797 __exceptionPreprocess + 250
1   libobjc.A.dylib                     0x00007fff6b9aba9e objc_exception_throw + 48
2   Realm                               0x0000000105053978 -[RLMRealm addNotificationBlock:] + 0
3   Realm                               0x000000010505d089 -[RLMResults addNotificationBlock:] + 52
4   RealmSwift                          0x0000000104d5ab5b $s10RealmSwift7ResultsV7observeySo20RLMNotificationTokenCyAA0A16CollectionChangeOyACyxGGcF + 203
5   RxRealm                             0x0000000104b32681 $s10RealmSwift03AnyA10CollectionVyxG02RxA019NotificationEmitterA2eFP7observeySo20RLMNotificationTokenCyAA0aD6ChangeOyxGcFTWTm + 113
6   RxRealm                             0x0000000104b32606 $s10RealmSwift7ResultsVyxG02RxA019NotificationEmitterA2eFP7observeySo20RLMNotificationTokenCyAA0A16CollectionChangeOyxGcFTW + 38
7   RxRealm                             0x0000000104b32b09 $s7RxSwift14ObservableTypeP0A5RealmAD19NotificationEmitter7ElementRpzrlE10collection4from16synchronousStartAA0C0CyAGGAG_SbtFZAA10Disposable_pAA11AnyObserverVyAGGcfU_ + 265
8   RxRealm                             0x0000000104b35dd6 $s7RxSwift14ObservableTypeP0A5RealmAD19NotificationEmitter7ElementRpzrlE10collection4from16synchronousStartAA0C0CyAGGAG_SbtFZAA10Disposable_pAA11AnyObserverVyAGGcfU_TATm + 38
9   RxRealm                             0x0000000104b35c90 $s7RxSwift14ObservableTypeP0A5RealmAD19NotificationEmitter7ElementRpzrlE10collection4from16synchronousStartAA0C0CyAGGAG_SbtFZAA10Disposable_pAA11AnyObserverVyAGGcfU_TA + 16
10  RxSwift                             0x0000000104b8f84c $s7RxSwift19AnonymousObservable33_95EBF5692819D58425EC2DD0512D115ALLC3run_6cancelAA10Disposable_p4sink_AaG_p12subscriptiontqd___AA10Cancelable_pt7ElementQyd__RszAA12ObserverTypeRd__lF + 316
11  RxSwift                             0x0000000104b9db6e $s7RxSwift8ProducerC9subscribeyAA10Disposable_pqd__7ElementQyd__RszAA12ObserverTypeRd__lFAaE_pyt_tcfU_ + 366
12  RxSwift                             0x0000000104b9dc09 $s7RxSwift8ProducerC9subscribeyAA10Disposable_pqd__7ElementQyd__RszAA12ObserverTypeRd__lFAaE_pyt_tcfU_TA + 25
13  RxSwift                             0x0000000104b9dc41 $s7RxSwift10Disposable_pIegr_ytAaB_pIegnr_TRTA + 17
14  RxSwift                             0x0000000104b95220 $s7RxSwift22CurrentThreadSchedulerC8schedule_6actionAA10Disposable_px_AaF_pxctlF + 288
15  RxSwift                             0x0000000104b9d6b8 $s7RxSwift8ProducerC9subscribeyAA10Disposable_pqd__7ElementQyd__RszAA12ObserverTypeRd__lF + 648
16  RxSwift                             0x0000000104ba55c0 $s7RxSwift9MergeSink33_DDEA0423368B3B462AE46699A4D080E1LLC14subscribeInneryyAA10ObservableCy7ElementQy_GF + 480
17  RxSwift                             0x0000000104ba53bf $s7RxSwift9MergeSink33_DDEA0423368B3B462AE46699A4D080E1LLC2onyyAA5EventOyxGF + 1119
18  RxSwift                             0x0000000104ba6190 $s7RxSwift9MergeSink33_DDEA0423368B3B462AE46699A4D080E1LLCyxq_q0_GAA12ObserverTypeA2aFP2onyyAA5EventOy7ElementQzGFTW + 16
19  RxSwift                             0x0000000104b98103 $s7RxSwift4SinkC9forwardOnyyAA5EventOy7ElementQzGF + 99
20  RxSwift                             0x0000000104be0258 $s7RxSwift7MapSink33_5428EFA9A9B0C0340021B871D2E5AC01LLC2onyyAA5EventOyxGF + 552
21  RxSwift                             0x0000000104be03b0 $s7RxSwift7MapSink33_5428EFA9A9B0C0340021B871D2E5AC01LLCyxq_GAA12ObserverTypeA2aFP2onyyAA5EventOy7ElementQzGFTW + 16
22  RxSwift                             0x0000000104b98103 $s7RxSwift4SinkC9forwardOnyyAA5EventOy7ElementQzGF + 99
23  RxSwift                             0x0000000104b8f615 $s7RxSwift23AnonymousObservableSink33_95EBF5692819D58425EC2DD0512D115ALLC2onyyAA5EventOy7ElementQzGF + 325
24  RxSwift                             0x0000000104b8f700 $s7RxSwift23AnonymousObservableSink33_95EBF5692819D58425EC2DD0512D115ALLCyxGAA12ObserverTypeA2aFP2onyyAA5EventOy7ElementQzGFTW + 16
25  RxSwift                             0x0000000104bf02e3 $sTA + 67
26  RxSwift                             0x0000000104b711ec $s7RxSwift11AnyObserverV2onyyAA5EventOyxGF + 12
27  RxSwift                             0x0000000104bf00b6 $s7RxSwift12ObserverTypePAAE6onNextyy7ElementQzF + 166
28  RxRealm                             0x0000000104b32df8 $s7RxSwift14ObservableTypeP0A5RealmAD19NotificationEmitter7ElementRpzrlE10collection4from16synchronousStartAA0C0CyAGGAG_SbtFZAA10Disposable_pAA11AnyObserverVyAGGcfU_y0eB00E16CollectionChangeOyAGGcfU_ + 568
29  RxRealm                             0x0000000104b378c9 $s7RxSwift14ObservableTypeP0A5RealmAD19NotificationEmitter7ElementRpzrlE10collection4from16synchronousStartAA0C0CyAGGAG_SbtFZAA10Disposable_pAA11AnyObserverVyAGGcfU_y0eB00E16CollectionChangeOyAGGcfU_TA + 41
30  RxRealm                             0x0000000104b36ef4 $s10RealmSwift0A16CollectionChangeOyAA7ResultsVyxGGIegn_AGIegg_AA0aC5ValueRzlTRTA + 52
31  RealmSwift                          0x0000000104d5ba3b $s10RealmSwift7ResultsV7observeySo20RLMNotificationTokenCyAA0A16CollectionChangeOyACyxGGcFySo10RLMResultsCyyXlGSg_So013RLMCollectionH0CSgs5Error_pSgtcfU_TA + 107
32  RealmSwift                          0x0000000104d3c47e $sSo10RLMResultsCyyXlGSgSo19RLMCollectionChangeCSgs5Error_pSgIegggg_AdGSo7NSErrorCSgIeyByyy_TR + 94
33  Realm                               0x0000000104fd69be _ZZ23RLMAddNotificationBlockIN5realm7ResultsEEP20RLMNotificationTokenP11objc_objectRT_U13block_pointerFvS5_P19RLMCollectionChangeP7NSErrorEbENKUlRKNS0_19CollectionChangeSetESt13exception_ptrE_clESG_SH_ + 198
34  Realm                               0x0000000104fd67b4 _ZN5realm24CollectionChangeCallback4ImplIZ23RLMAddNotificationBlockINS_7ResultsEEP20RLMNotificationTokenP11objc_objectRT_U13block_pointerFvS7_P19RLMCollectionChangeP7NSErrorEbEUlRKNS_19CollectionChangeSetESt13exception_ptrE_E5afterESI_ + 26
35  Realm                               0x0000000104f8553f _ZN5realm5_impl18CollectionNotifier13after_advanceEv + 399
36  Realm                               0x0000000104f8619d _ZN5realm5_impl15NotifierPackage13after_advanceEv + 35
37  Realm                               0x00000001050a7adb _ZN5realm5_impl11transaction5beginERKNSt3__110unique_ptrINS_11SharedGroupENS2_14default_deleteIS4_EEEEPNS_14BindingContextERNS0_15NotifierPackageE + 468
38  Realm                               0x0000000104fb337b _ZN5realm5_impl16RealmCoordinator16promote_to_writeERNS_5RealmE + 157
39  Realm                               0x0000000105087dd6 _ZN5realm5Realm17begin_transactionEv + 180
40  Realm                               0x0000000105053e1c -[RLMRealm beginWriteTransaction] + 15
41  ConfCore                            0x0000000104978054 block_destroy_helper + 86388
42  ConfCore                            0x000000010490eba9 globalinit_33_B8BAEC25FCBA0721953811C918E440CD_func2 + 2313
43  libdispatch.dylib                   0x00007fff6caf06c4 _dispatch_call_block_and_release + 12
44  libdispatch.dylib                   0x00007fff6caf1658 _dispatch_client_callout + 8
45  libdispatch.dylib                   0x00007fff6cafccab _dispatch_main_queue_callback_4CF + 936
46  CoreFoundation                      0x00007fff32adbb93 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
47  CoreFoundation                      0x00007fff32a9b81a __CFRunLoopRun + 2042
48  CoreFoundation                      0x00007fff32a9a9c3 CFRunLoopRunSpecific + 466
49  HIToolbox                           0x00007fff316b7abd RunCurrentEventLoopInMode + 292
50  HIToolbox                           0x00007fff316b77d5 ReceiveNextEventCommon + 584
51  HIToolbox                           0x00007fff316b7579 _BlockUntilNextEventMatchingListInModeWithFilter + 64
52  AppKit                              0x00007fff2fcff829 _DPSNextEvent + 883
53  AppKit                              0x00007fff2fcfe070 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
54  AppKit                              0x00007fff2fcefd7e -[NSApplication run] + 658
55  AppKit                              0x00007fff2fcc1b86 NSApplicationMain + 777
56  libdyld.dylib                       0x00007fff6cb4acc9 start + 1

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.AppKit              	0x00007fff300e1b43 -[NSApplication _crashOnException:] + 106
1   com.apple.AppKit              	0x00007fff300e1a26 -[NSApplication reportException:] + 901
2   com.apple.AppKit              	0x00007fff3019155d uncaughtErrorProc + 145
3   com.apple.CoreFoundation      	0x00007fff32b916b8 __handleUncaughtException + 726
4   libobjc.A.dylib               	0x00007fff6b9ada51 _objc_terminate() + 90
5   libc++abi.dylib               	0x00007fff69e80887 std::__terminate(void (*)()) + 8
6   libc++abi.dylib               	0x00007fff69e80829 std::terminate() + 41
7   libdispatch.dylib             	0x00007fff6caf166c _dispatch_client_callout + 28
8   libdispatch.dylib             	0x00007fff6cafccab _dispatch_main_queue_callback_4CF + 936
9   com.apple.CoreFoundation      	0x00007fff32adbb93 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
10  com.apple.CoreFoundation      	0x00007fff32a9b81a __CFRunLoopRun + 2042
11  com.apple.CoreFoundation      	0x00007fff32a9a9c3 CFRunLoopRunSpecific + 466
12  com.apple.HIToolbox           	0x00007fff316b7abd RunCurrentEventLoopInMode + 292
13  com.apple.HIToolbox           	0x00007fff316b77d5 ReceiveNextEventCommon + 584
14  com.apple.HIToolbox           	0x00007fff316b7579 _BlockUntilNextEventMatchingListInModeWithFilter + 64
15  com.apple.AppKit              	0x00007fff2fcff829 _DPSNextEvent + 883
16  com.apple.AppKit              	0x00007fff2fcfe070 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
17  com.apple.AppKit              	0x00007fff2fcefd7e -[NSApplication run] + 658
18  com.apple.AppKit              	0x00007fff2fcc1b86 NSApplicationMain + 777
19  libdyld.dylib                 	0x00007fff6cb4acc9 start + 1

@tkrajacic This crash has nothing to do with the issue mentioned above. I will move it into another issue. Edit: moved to #615

Fixed in 7.1