title: iOS Integration Tests randomly crash: Encountered an XPC error while communicating with backboardd
body: <p>When running integration tests w/ live requests against a server, sometimes I get the following crash. Does anyone have an idea why?</p>
  
  <p>I'm currently on OS X Mavericks and running these tests on the iOS 7.0.3 SDK and Jenkins.</p>
  
  <pre><code>2014-01-23 14:55:47.178 xctest[74229:303] 200 &lt;- https://site/30012.zipjson?deltadate=2014-02-22T16%3A31%3A56.000Z&amp;encrypt=N
  2014-01-23 14:55:47.186 xctest[74229:303] GET -&gt; https://site/30012.zipjson?deltadate=2014-02-22T16%3A31%3A56.000Z&amp;encrypt=N
  2014-01-23 14:55:52.456 xctest[74229:303] 200 &lt;- https://site/30012.zipjson?deltadate=2014-02-22T16%3A31%3A56.000Z&amp;encrypt=N
  2014-01-23 14:55:52.467 xctest[74229:303] GET -&gt; https://site/30012.zipjson?deltadate=2014-02-22T16%3A31%3A56.000Z&amp;encrypt=N
  2014-01-23 14:55:52.784 xctest[74229:270b] Encountered an XPC error while communicating with backboardd: &lt;error: 0x15bb6a4&gt; { count = 1, contents =
      "XPCErrorDescription" =&gt; &lt;string: 0x15bb884&gt; { length = 18, contents = "Connection invalid" }
  }
  2014-01-23 14:55:52.784 xctest[74229:2e0f] TASK-ASSERT: cfurlcache - ProcessCacheTask - FAILED to get task-assertion, going commando with 2 items to process.
  2014-01-23 14:55:56.470 xctest[74229:303] 200 &lt;- https:/site/30012.zipjson?deltadate=2014-02-22T16%3A31%3A56.000Z&amp;encrypt=N
  2014-01-23 14:55:56.518 xctest[74229:303] GET -&gt; https://site/30012.zipjson?deltadate=2014-02-22T16%3A31%3A56.000Z&amp;encrypt=N
  2014-01-23 14:56:00.836 xctest[74229:303] 200 &lt;- https://site/30012.zipjson?deltadate=2014-02-22T16%3A31%3A56.000Z&amp;encrypt=N
  2014-01-23 14:56:00.876 xctest[74229:303] GET -&gt; https://site/30012.zipjson?deltadate=2014-02-22T16%3A31%3A56.000Z&amp;encrypt=N
  2014-01-23 14:56:02.785 xctest[74229:2e0f] TASK-ASSERT: cfurlcache - ProcessCacheTask - FAILED to get task-assertion, going commando with 2 items to process.
  2014-01-23 14:56:02.785 xctest[74229:e03] Encountered an XPC error while communicating with backboardd: &lt;error: 0x15bb6a4&gt; { count = 1, contents =
      "XPCErrorDescription" =&gt; &lt;string: 0x15bb884&gt; { length = 18, contents = "Connection invalid" }
  }
  2014-01-23 14:56:07.330 xctest[74229:303] 200 &lt;- https://site/30012.zipjson?deltadate=2014-02-22T16%3A31%3A56.000Z&amp;encrypt=N
  2014-01-23 14:56:07.392 xctest[74229:303] GET -&gt; https://site/30012.zipjson?deltadate=2014-02-22T16%3A31%3A56.000Z&amp;encrypt=N
  2014-01-23 14:56:12.786 xctest[74229:1703] TASK-ASSERT: cfurlcache - ProcessCacheTask - FAILED to get task-assertion, going commando with 1 items to process.
  2014-01-23 14:56:12.786 xctest[74229:270b] Encountered an XPC error while communicating with backboardd: &lt;error: 0x15bb6a4&gt; { count = 1, contents =
      "XPCErrorDescription" =&gt; &lt;string: 0x15bb884&gt; { length = 18, contents = "Connection invalid" }
  }
  Test crashed while running.
  
  CRASH REPORT: xctest_2014-01-23-145619_Jenkinss-Mac-mini.crash
  
  Process:         xctest [74229]
  Path:            /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/Developer/usr/bin/xctest
  Identifier:      xctest
  Version:         11
  Code Type:       X86 (Native)
  Parent Process:  sim [74182]
  Responsible:     Terminal [1058]
  User ID:         501
  
  Date/Time:       2014-01-23 14:56:12.852 -0600
  OS Version:      Mac OS X 10.9.1 (13B42)
  Report Version:  11
  Anonymous UUID:  1E15282E-FD52-64B4-798E-2ADBDF3979B5
  
  Sleep/Wake UUID: 4DAEB09F-C4D4-4A7E-BF75-7C73D217FE3B
  
  Crashed Thread:  7  Dispatch queue: com.apple.backboardservices.processassertion
  
  Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
  Exception Codes: KERN_INVALID_ADDRESS at 0x000000003000000c
  
  VM Regions Near 0x3000000c:
      __LINKEDIT             000000002010c000-0000000020112000 [   24K] r--/rwx SM=COW  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/Developer/Library/Frameworks/XCTest.framework/XCTest
  --&gt; 
      __TEXT                 000000008fe47000-000000008fe7a000 [  204K] r-x/rwx SM=COW  /usr/lib/dyld
  
  Application Specific Information:
  objc_msgSend() selector name: queue_invalidate:
  iPhone Simulator (external launch) , iPhone OS 7.0.3 (unknown/11B508)
  
  
  Thread 0:: Dispatch queue: com.apple.main-thread
  0   libsystem_kernel.dylib          0x01794f7a mach_msg_trap + 10
  1   libsystem_kernel.dylib          0x0179416c mach_msg + 68
  2   CoreFoundation                  0x00acbe49 __CFRunLoopServiceMachPort + 169
  3   CoreFoundation                  0x00ad144d __CFRunLoopRun + 1341
  4   CoreFoundation                  0x00ad0ac3 CFRunLoopRunSpecific + 467
  5   CoreFoundation                  0x00ad08db CFRunLoopRunInMode + 123
  6   Foundation                      0x0009b9c5 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 284
  7   Foundation                      0x0009b865 -[NSRunLoop(NSRunLoop) runUntilDate:] + 88
  8   nLinkIntegrationTests           0x066c1ad1 +[MDTTestHelpers wait:secondsForBlock:] + 449 (MDTTestHelpers.m:27)
  9   nLinkIntegrationTests           0x067c802d -[MDTCookieStressTest testTryToBreakAuthentication] + 941 (MDTCookieStressTest.m:39)
  10  CoreFoundation                  0x00b1fd1d __invoking___ + 29
  11  CoreFoundation                  0x00b1fc2a -[NSInvocation invoke] + 362
  12  XCTest                          0x201032bf -[XCTestCase invokeTest] + 212
  13  XCTest                          0x2010338d -[XCTestCase performTest:] + 111
  14  otest-shim-ios.dylib            0x00008d45 XCPerformTestWithSuppressedExpectedAssertionFailures + 172 (otest-shim.m:357)
  15  otest-shim-ios.dylib            0x00008c94 XCTestCase_performTest + 32 (otest-shim.m:371)
  16  XCTest                          0x2010417c -[XCTest run] + 82
  17  XCTest                          0x20102a44 -[XCTestSuite performTest:] + 139
  18  XCTest                          0x2010417c -[XCTest run] + 82
  19  XCTest                          0x20102a44 -[XCTestSuite performTest:] + 139
  20  XCTest                          0x2010417c -[XCTest run] + 82
  21  XCTest                          0x20102a44 -[XCTestSuite performTest:] + 139
  22  XCTest                          0x2010417c -[XCTest run] + 82
  23  XCTest                          0x20105aa1 +[XCTestProbe runTests:] + 183
  24  libobjc.A.dylib                 0x007b5737 +[NSObject performSelector:withObject:] + 70
  25  xctest                          0x0000233e 0x1000 + 4926
  26  xctest                          0x00002590 0x1000 + 5520
  27  xctest                          0x00002671 0x1000 + 5745
  28  xctest                          0x00002007 0x1000 + 4103
  29  libdyld.dylib                   0x0166370d start + 1
  
  Thread 1:: Dispatch queue: com.apple.libdispatch-manager
  0   libsystem_kernel.dylib          0x0179a992 kevent64 + 10
  1   libdispatch.dylib               0x013c2f3e _dispatch_mgr_invoke + 238
  2   libdispatch.dylib               0x013c2c7a _dispatch_mgr_thread + 60
  
  Thread 2:
  0   libsystem_kernel.dylib          0x0179a046 __workq_kernreturn + 10
  1   libsystem_pthread.dylib         0x0175ddcf _pthread_wqthread + 372
  2   libsystem_pthread.dylib         0x01761cce start_wqthread + 30
  
  Thread 3:
  0   libsystem_kernel.dylib          0x0179a046 __workq_kernreturn + 10
  1   libsystem_pthread.dylib         0x0175ddcf _pthread_wqthread + 372
  2   libsystem_pthread.dylib         0x01761cce start_wqthread + 30
  
  Thread 4:: AFNetworking
  0   libsystem_kernel.dylib          0x01794f7a mach_msg_trap + 10
  1   libsystem_kernel.dylib          0x0179416c mach_msg + 68
  2   CoreFoundation                  0x00acbe49 __CFRunLoopServiceMachPort + 169
  3   CoreFoundation                  0x00ad13b1 __CFRunLoopRun + 1185
  4   CoreFoundation                  0x00ad0ac3 CFRunLoopRunSpecific + 467
  5   CoreFoundation                  0x00ad08db CFRunLoopRunInMode + 123
  6   Foundation                      0x0009b9c5 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 284
  7   Foundation                      0x000378d1 -[NSRunLoop(NSRunLoop) run] + 82
  8   nLinkIntegrationTests           0x068475eb +[AFURLConnectionOperation networkRequestThreadEntryPoint:] + 315 (AFURLConnectionOperation.m:185)
  9   Foundation                      0x00096597 -[NSThread main] + 76
  10  Foundation                      0x000964f6 __NSThread__main__ + 1275
  11  libsystem_pthread.dylib         0x0175c5fb _pthread_body + 144
  12  libsystem_pthread.dylib         0x0175c485 _pthread_start + 130
  13  libsystem_pthread.dylib         0x01761cf2 thread_start + 34
  
  Thread 5:: com.apple.NSURLConnectionLoader
  0   libsystem_kernel.dylib          0x01794f7a mach_msg_trap + 10
  1   libsystem_kernel.dylib          0x0179416c mach_msg + 68
  2   CoreFoundation                  0x00acbe49 __CFRunLoopServiceMachPort + 169
  3   CoreFoundation                  0x00ad13b1 __CFRunLoopRun + 1185
  4   CoreFoundation                  0x00ad0ac3 CFRunLoopRunSpecific + 467
  5   CoreFoundation                  0x00ad08db CFRunLoopRunInMode + 123
  6   Foundation                      0x0003a9de +[NSURLConnection(Loader) _resourceLoadLoop:] + 381
  7   Foundation                      0x00096597 -[NSThread main] + 76
  8   Foundation                      0x000964f6 __NSThread__main__ + 1275
  9   libsystem_pthread.dylib         0x0175c5fb _pthread_body + 144
  10  libsystem_pthread.dylib         0x0175c485 _pthread_start + 130
  11  libsystem_pthread.dylib         0x01761cf2 thread_start + 34
  
  Thread 6:: com.apple.CFSocket.private
  0   libsystem_kernel.dylib          0x01799ace __select + 10
  1   CoreFoundation                  0x00b0f3eb __CFSocketManager + 875
  2   libsystem_pthread.dylib         0x0175c5fb _pthread_body + 144
  3   libsystem_pthread.dylib         0x0175c485 _pthread_start + 130
  4   libsystem_pthread.dylib         0x01761cf2 thread_start + 34
  
  Thread 7 Crashed:: Dispatch queue: com.apple.backboardservices.processassertion
  0   libobjc.A.dylib                 0x007b30b2 objc_msgSend + 14
  1   BackBoardServices               0x019621db __47-[BKSProcessAssertion queue_registerWithServer]_block_invoke + 197
  2   libxpc.dylib                    0x01594008 _xpc_connection_call_event_handler + 65
  3   libxpc.dylib                    0x01593ac5 _xpc_connection_mach_event + 1687
  4   libdispatch.dylib               0x013d1590 _dispatch_client_callout4 + 37
  5   libdispatch.dylib               0x013c4ef0 _dispatch_mach_cancel_invoke + 61
  6   libdispatch.dylib               0x013c415f _dispatch_mach_invoke + 378
  7   libdispatch.dylib               0x013bf00f _dispatch_queue_drain + 340
  8   libdispatch.dylib               0x013bee7a _dispatch_queue_invoke + 128
  9   libdispatch.dylib               0x013bfe1f _dispatch_root_queue_drain + 83
  10  libdispatch.dylib               0x013c0137 _dispatch_worker_thread2 + 39
  11  libsystem_pthread.dylib         0x0175ddab _pthread_wqthread + 336
  12  libsystem_pthread.dylib         0x01761cce start_wqthread + 30
  
  Thread 8:
  0   libsystem_kernel.dylib          0x0179a046 __workq_kernreturn + 10
  1   libsystem_pthread.dylib         0x0175ddcf _pthread_wqthread + 372
  2   libsystem_pthread.dylib         0x01761cce start_wqthread + 30
  
  Thread 7 crashed with X86 Thread State (32-bit):
    eax: 0x0d42f710  ebx: 0x01962124  ecx: 0x0197847b  edx: 0x30000000
    edi: 0x015bb6a4  esi: 0x015bb6a4  ebp: 0xb029ad68  esp: 0xb029ad3c
     ss: 0x00000023  efl: 0x00010202  eip: 0x007b30b2   cs: 0x0000001b
     ds: 0x00000023   es: 0x00000023   fs: 0x00000023   gs: 0x0000000f
    cr2: 0x3000000c
  
  Logical CPU:     2
  Error Code:      0x00000004
  Trap Number:     14
  --------------------------------------------------------------------------------
  </code></pre>