DTDeviceKit: Could not start house arrest service

Originator:jp
Number:rdar://31117325 Date Originated:17-Mar-2017 11:00 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-8.2 (8C38)
Classification:Serious Bug Reproducible:Sometimes
 
Summary:
When attempting to run unit tests on an attached iOS device (iPhone 5 running iOS 8.1.3), I get the following error reported by Xcode.

DTDeviceKit: Could not start house arrest service for app identifier io.realm.TestHost [Error Domain=com.apple.dtdevicekit Code=-402653093 "Too many instances of this service are already running." UserInfo={NSLocalizedFailureReason=Too many instances of this service are already running.

I get this error with both xcodebuild and Xcode GUI, with all flavors of Xcode 8: 8.0, 8.1, 8.2 and 8.3 beta 4.

Steps to Reproduce:
This might be unique to this test device.

Expected Results:
Device tests should run successfully.

Actual Results:

```
writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/bj/n03qf0s968d07kcp9bc4v_vw0000gl/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/437e7a00c5ec4693ecc600285fb58ff6/ea7aa85c000517b3ae2260c09a32c2bd193c3304/ManifestCache.plist
2017-03-17 10:50:34.612 xcodebuild[3069:18190]  DTDeviceKit: Could not start house arrest service for app identifier io.realm.TestHost [Error Domain=com.apple.dtdevicekit Code=-402653093 "Too many instances of this service are already running." UserInfo={NSLocalizedFailureReason=Too many instances of this service are already running., com.apple.dtdevicekit.stacktrace=(
  0   DTDeviceKitBase                     0x000000010e0be37b DTDKCreateNSError + 113
  1   DTDeviceKitBase                     0x000000010e0beab9 DTDK_AMDErrorToNSError + 791
  2   DTDeviceKitBase                     0x000000010e0d02a5 __70-[DTDKRemoteDeviceConnection startHouseArrestServiceForAppIdentifier:]_block_invoke + 100
  3   DTDeviceKitBase                     0x000000010e0cf181 __48-[DTDKRemoteDeviceConnection futureWithSession:]_block_invoke_4 + 22
  4   DTDeviceKitBase                     0x000000010e0c12c7 __DTDKExecuteInSession_block_invoke + 38
  5   DTDeviceKitBase                     0x000000010e0c08f0 __DTDKExecuteWithConnection_block_invoke_2 + 477
  6   DTDeviceKitBase                     0x000000010e0c06ec __DTDKExecuteWithConnection_block_invoke + 107
  7   libdispatch.dylib                   0x00007fff8c5750b8 _dispatch_client_callout + 8
  8   libdispatch.dylib                   0x00007fff8c575cf2 _dispatch_barrier_sync_f_invoke + 83
  9   libdispatch.dylib                   0x00007fff8c58060c _dispatch_barrier_sync_f_slow + 540
  10  DVTFoundation                       0x000000010531f96b DVTDispatchBarrierSync + 206
  11  DVTFoundation                       0x00000001052fc317 -[DVTDispatchLock performLockedBlock:] + 116
  12  DTDeviceKitBase                     0x000000010e0c05f6 DTDKExecuteWithConnection + 223
  13  DTDeviceKitBase                     0x000000010e0c1251 DTDKExecuteInSession + 121
  14  DTDeviceKitBase                     0x000000010e0cf0b8 __48-[DTDKRemoteDeviceConnection futureWithSession:]_block_invoke_3 + 117
  15  DVTFoundation                       0x000000010531ecc7 __DVTDispatchAsync_block_invoke + 827
  16  libdispatch.dylib                   0x00007fff8c57def7 _dispatch_call_block_and_release + 12
  17  libdispatch.dylib                   0x00007fff8c5750b8 _dispatch_client_callout + 8
  18  libdispatch.dylib                   0x00007fff8c58ab5b _dispatch_continuation_pop + 533
  19  libdispatch.dylib                   0x00007fff8c581e3b _dispatch_async_redirect_invoke + 734
  20  libdispatch.dylib                   0x00007fff8c576e70 _dispatch_root_queue_drain + 476
  21  libdispatch.dylib                   0x00007fff8c576c47 _dispatch_worker_thread3 + 99
  22  libsystem_pthread.dylib             0x00007fff8c7c2712 _pthread_wqthread + 1299
  23  libsystem_pthread.dylib             0x00007fff8c7c21ed start_wqthread + 13
), NSLocalizedRecoverySuggestion=Too many instances of this service are already running., NSLocalizedDescription=Too many instances of this service are already running.}]
2017-03-17 10:50:36.536 xcodebuild[3069:15878] Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}

Testing failed:
  Test target Tests encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)
** TEST FAILED **
```

Regression:
Describe circumstances where the problem occurs or does not occur, such as software versions and/or hardware configurations.

Notes:
Provide additional information, such as references to related problems, workarounds and relevant attachments.

Comments

Duplicate of 29323240 (Open)

Engineering has determined that your bug report is a duplicate of another issue and will be closed.

The open or closed status of the original bug report your issue was duplicated to appears in the yellow "Duplicate of XXXXXXXX" section of the bug reporter user interface. This section appears near the top of the right column's bug detail view just under the bug number, title, state, product and rank.

If you have any questions or concerns, please update your report directly here: http://bugreport.apple.com/.

Additional logs by by JP Simard on 17-Mar-2017 11:38 AM

`

11:36:17.749 Xcode[5637:33808] Beginning test session Tests-7127CFDF-A842-4C7F-A4C6-8049EC4DEDD5 at 2017-03-17 11:36:17.748 with Xcode 8W143q on target { deviceSerialNumber: DQGK21JSDTTN identifier: ea7aa85c000517b3ae2260c09a32c2bd193c3304 deviceClass: iPhone deviceName: Realm’s iPhone deviceIdentifier: ea7aa85c000517b3ae2260c09a32c2bd193c3304 productVersion: 8.1.3 buildVersion: 12B466 deviceSoftwareVersion: 8.1.3 (12B466) deviceArchitecture: armv7s deviceTotalCapacity: 13588221952 deviceAvailableCapacity: 12190986240 deviceIsTransient: NO ignored: NO deviceIsBusy: NO deviceIsActivated: YES deviceActivationState: Activated isPasscodeLocked: NO deviceType: supportedDeviceFamilies: ( 1 ) applications: {( )} provisioningProfiles: {( )} activityProgress: -2 activityTitle:
hasInternalSupport: NO isSupportedOS: YES developerDiskMountError: (null) (null) bootArgs: } (8.1.3 (12B466)) 11:36:17.749 Xcode[5637:33808] Launching with Xcode.DebuggerFoundation.Launcher.LLDB 11:36:17.755 Xcode[5637:35767] Connecting to mobile device: ea7aa85c000517b3ae2260c09a32c2bd193c3304 11:36:17.759 Xcode[5637:35767] Starting session with mobile device 11:36:17.787 Xcode[5637:35767] Starting test manager service on mobile device. 11:36:17.834 Xcode[5637:36758] Received connection for test runner session 11:36:17.834 Xcode[5637:36758] Listening for proxy connection request from the test bundle 11:36:17.834 Xcode[5637:33808] Test runner session acquired connection. 11:36:17.834 Xcode[5637:33808] Waiting for test process to launch. 11:36:17.835 Xcode[5637:36758] Initiating session with identifier: 7127CFDF-A842-4C7F-A4C6-8049EC4DEDD5 11:36:17.868 Xcode[5637:36761] Got reply to session initiation request with identifier 7127CFDF-A842-4C7F-A4C6-8049EC4DEDD5 (result:error): (null): Error Domain=DTXMessage Code=1 "(null)" UserInfo={DTXExceptionKey=Unable to invoke -[ IDEinitiateSessionWithIdentifier:forClient:atPath:protocolVersion:] - it does not respond to the selector} (old API) 11:36:18.177 Xcode[5637:33808] Launch session started. 11:36:18.295 Xcode[5637:36758] Installing io.realm.TestHost using MobileInstall 11:36:18.441 Xcode[5637:36836] app uninstall set - {( )} 11:36:18.441 Xcode[5637:36836] app install set - {( )} 11:36:18.591 Xcode[5637:36836] installApplicationBundleAtPath:withOptions:andError:withCallback: failed with { NSLocalizedDescription = "App installation failed"; NSLocalizedFailureReason = "The file already exists."; NSLocalizedRecoverySuggestion = "The file already exists."; "com.apple.dtdevicekit.stacktrace" = ( 0 DTDeviceKitBase 0x000000011905208d DTDKCreateNSError + 113 1 DTDeviceKitBase 0x0000000119052775 DTDK_AMDErrorToNSError + 789 2 DTDeviceKitBase 0x000000011909150d _90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]block_invoke + 158 3 DVTFoundation 0x000000010cf007d9 DVTInvokeWithStrongOwnership + 75 4 DTDeviceKitBase 0x0000000119091248 -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1133 5 IDEiOSSupportCore 0x0000000118f6d356 _118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]block_invoke.336 + 4154 6 DVTFoundation 0x000000010d02a766 _DVTDispatchAsyncblock_invoke + 820 7 libdispatch.dylib 0x00007fff8c57def7 dispatchcall_block_and_release + 12 8 libdispatch.dylib 0x00007fff8c5750b8 dispatchclient_callout + 8 9 libdispatch.dylib 0x00007fff8c58bae5 dispatchqueue_serial_drain + 896 10 libdispatch.dylib 0x00007fff8c57dcd9 dispatchqueue_invoke + 1046 11 libdispatch.dylib 0x00007fff8c576e70 dispatchroot_queue_drain + 476 12 libdispatch.dylib 0x00007fff8c576c47 dispatchworker_thread3 + 99 13 libsystem_pthread.dylib 0x00007fff8c7c2712 pthreadwqthread + 1299 14 libsystem_pthread.dylib 0x00007fff8c7c21ed start_wqthread + 13 ); } 11:36:18.778 Xcode[5637:36758] Failed to install /Users/realm/Library/Developer/Xcode/DerivedData/Realm-ejzvekpjtuifhxaykigwnssdiqen/Build/Products/Debug-iphoneos/TestHost.app - error Error Domain=com.apple.dtdevicekit Code=-402653168 "App installation failed" UserInfo={NSLocalizedFailureReason=The file already exists., com.apple.dtdevicekit.stacktrace=( 0 DTDeviceKitBase 0x000000011905208d DTDKCreateNSError + 113 1 DTDeviceKitBase 0x0000000119052775 DTDK_AMDErrorToNSError + 789 2 DTDeviceKitBase 0x000000011909150d _90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]block_invoke + 158 3 DVTFoundation 0x000000010cf007d9 DVTInvokeWithStrongOwnership + 75 4 DTDeviceKitBase 0x0000000119091248 -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1133 5 IDEiOSSupportCore 0x0000000118f6d356 _118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]block_invoke.336 + 4154 6 DVTFoundation 0x000000010d02a766 _DVTDispatchAsyncblock_invoke + 820 7 libdispatch.dylib 0x00007fff8c57def7 dispatchcall_block_and_release + 12 8 libdispatch.dylib 0x00007fff8c5750b8 dispatchclient_callout + 8 9 libdispatch.dylib 0x00007fff8c58bae5 dispatchqueue_serial_drain + 896 10 libdispatch.dylib 0x00007fff8c57dcd9 dispatchqueue_invoke + 1046 11 libdispatch.dylib 0x00007fff8c576e70 dispatchroot_queue_drain + 476 12 libdispatch.dylib 0x00007fff8c576c47 dispatchworker_thread3 + 99 13 libsystem_pthread.dylib 0x00007fff8c7c2712 pthreadwqthread + 1299 14 libsystem_pthread.dylib 0x00007fff8c7c21ed start_wqthread + 13 ), NSLocalizedRecoverySuggestion=The file already exists., NSLocalizedDescription=App installation failed} 11:36:18.784 Xcode[5637:33808] Test operation failure: Launch session expired before checking in. 11:36:18.784 Xcode[5637:33808] _finishWithError:Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Launch session expired before checking in." UserInfo={NSLocalizedDescription=Launch session expired before checking in.} didCancel: 1

`

Comment by JP Simard on 17-Mar-2017 11:33 AM

After resetting the phone to factory defaults (Reset All Content and Settings), I'm now getting the following error: "The file already exists."

` writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/bj/n03qf0s968d07kcp9bc4v_vw0000gl/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/437e7a00c5ec4693ecc600285fb58ff6/ea7aa85c000517b3ae2260c09a32c2bd193c3304/ManifestCache.plist 2017-03-17 11:29:21.260 xcodebuild[5574:33574] Error Domain=com.apple.dtdevicekit Code=-402653168 "App installation failed" UserInfo={NSLocalizedFailureReason=The file already exists., com.apple.dtdevicekit.stacktrace=( 0 DTDeviceKitBase 0x000000010f70337b DTDKCreateNSError + 113 1 DTDeviceKitBase 0x000000010f703ab9 DTDK_AMDErrorToNSError + 791 2 DTDeviceKitBase 0x000000010f7439df _90-[DTDKRemoteDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]block_invoke + 158 3 DVTFoundation 0x000000010696c999 DVTInvokeWithStrongOwnership + 75 4 DTDeviceKitBase 0x000000010f743725 -[DTDKRemoteDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1181 5 IDEiOSSupportCore 0x000000010f639e1f _118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]block_invoke.336 + 4597 6 DVTFoundation 0x0000000106a90cc7 _DVTDispatchAsyncblock_invoke + 827 7 libdispatch.dylib 0x00007fff8c57def7 dispatchcall_block_and_release + 12 8 libdispatch.dylib 0x00007fff8c5750b8 dispatchclient_callout + 8 9 libdispatch.dylib 0x00007fff8c58bae5 dispatchqueue_serial_drain + 896 10 libdispatch.dylib 0x00007fff8c57dcd9 dispatchqueue_invoke + 1046 11 libdispatch.dylib 0x00007fff8c576e70 dispatchroot_queue_drain + 476 12 libdispatch.dylib 0x00007fff8c576c47 dispatchworker_thread3 + 99 13 libsystem_pthread.dylib 0x00007fff8c7c2712 pthreadwqthread + 1299 14 libsystem_pthread.dylib 0x00007fff8c7c21ed start_wqthread + 13 ), NSLocalizedRecoverySuggestion=The file already exists., NSLocalizedDescription=App installation failed} 2017-03-17 11:29:21.260 xcodebuild[5574:33574] Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}

Testing failed: Test target Tests encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted) TEST FAILED

`


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!