title: NSApplication applicationShouldTerminate called before applicationDidFinishLaunching
body: <p>I've got a strange problem: got a singleton which is initialized in <code>applicationDidFinishLaunching</code> of <code>AppDelegate</code>, but in some cases I receive crash reports with <code>EXC_CRASH</code> (<code>SIGSEGV</code>) and a stack trace like this:</p>
  
  <pre><code>0   com.name.myapp                  0x000000010f723bae -[MySingleton .cxx_construct] (common_bootstrap.h:57)
  1   libobjc.A.dylib                 0x00007fff91339baa object_cxxConstructFromClass(objc_object*, objc_class*) + 151
  2   libobjc.A.dylib                 0x00007fff913367e4 object_cxxConstruct + 25
  3   libobjc.A.dylib                 0x00007fff91336795 _objc_constructOrFree + 21
  4   libobjc.A.dylib                 0x00007fff9134a49d +[NSObject allocWithZone:] + 16
  5   com.name.myapp                  0x000000010f722a11 __32+[MySingleton sharedInstance]_block_invoke (MySingleton.mm:124)
  6   libdispatch.dylib               0x00007fff9377a2ad _dispatch_client_callout + 8
  7   libdispatch.dylib               0x00007fff9377a21c dispatch_once_f + 79
  8   com.name.myapp                  0x000000010f7229f5 +[MySingleton sharedInstance] (once.h:68)
  9   com.name.myapp                  0x000000010f719480 -[AppDelegate applicationShouldTerminate:] (AppDelegate.m:673)
  10  com.apple.AppKit                0x00007fff8d017471 -[NSApplication _docController:shouldTerminate:] + 69
  11  com.apple.AppKit                0x00007fff8d017383 __91-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke + 152
  12  com.apple.AppKit                0x00007fff8d017122 -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 1292
  13  com.apple.AppKit                0x00007fff8d016bbf -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 265
  14  com.apple.AppKit                0x00007fff8d01688c -[NSApplication _shouldTerminate] + 663
  15  com.apple.AppKit                0x00007fff8d052a34 -[NSApplication(NSAppleEventHandling) _handleAEQuit] + 357
  16  com.apple.AppKit                0x00007fff8ccb7213 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 282
  17  com.apple.Foundation            0x00007fff92bf1eaa -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 294
  18  com.apple.Foundation            0x00007fff92bf1d1d _NSAppleEventManagerGenericHandler + 106
  19  com.apple.AE                    0x00007fff8c139e1f aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 381
  20  com.apple.AE                    0x00007fff8c139c32 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 31
  21  com.apple.AE                    0x00007fff8c139b36 aeProcessAppleEvent + 315
  22  com.apple.HIToolbox             0x00007fff8bced5f1 AEProcessAppleEvent + 56
  23  com.apple.AppKit                0x00007fff8ccb30f6 _DPSNextEvent + 1026
  24  com.apple.AppKit                0x00007fff8ccb28db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
  25  com.apple.AppKit                0x00007fff8cca69cc -[NSApplication run] + 553
  26  com.apple.AppKit                0x00007fff8cc91803 NSApplicationMain + 940
  27  com.name.myapp                  0x000000010f716ec4 start + 52
  </code></pre>
  
  <p>So I see my singleton is trying to allocate and fails, so I suppose <code>applicationDidFinishLaunching</code> didn't ever been called.</p>
  
  <p>Why can OS X try to terminate my app before it has been launched?</p>