Instruments gets stuck in dyld::initializeMainExecutable in Xcode 11

Update: We can profile using the Allocations instrument, but not the Leaks instrument.


My company's app cannot be run under instruments (the leaks instrument, specifically). We have tried:

* Xcode 11

* Xcode 11 beta

* Various simulators

* Debug build

* Release build

* Rebooting the machine

* Trying on various machines


This is under Mojave 10.14.6


No matter what I do, the result is identical. The app works fine if I debug with Xcode, but if I launch with instruments it sticks at the launch screen. When I attach the debugger to the process and pause, I get this backtrace:


Thread 1 Queue : com.apple.main-thread (serial)


#0 0x0000000119b9e88a in syscall_thread_switch ()
#1 0x000000010b5df237 in _OSSpinLockLockYield ()
#2 0x000000010b5c123b in dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), bool, bool) ()
#3 0x000000010b5c9e85 in ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, bool, ImageLoader::RPathChain const&, char const*) ()
#4 0x000000010b5c1c86 in dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&, unsigned int) ()
#5 0x000000010b5c5f88 in dlopen_internal ()
#6 0x00007fff5198a9ed in dlopen ()
#7 0x00007fff50b1484a in imp_implementationWithBlock ()
#8 0x000000010b6635df in _swapMethods ()
#9 0x000000010b664b13 in _willInitializeClass ()
#10 0x00007fff50b01ea9 in initializeNonMetaClass ()
#11 0x00007fff50b01cc2 in initializeNonMetaClass ()
#12 0x00007fff50b01cc2 in initializeNonMetaClass ()
#13 0x00007fff50b024ba in initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt&, bool) ()
#14 0x00007fff50b0ca5d in lookUpImpOrForward ()
#15 0x00007fff50afd219 in _objc_msgSend_uncached ()
#16 0x000000010b5c1695 in dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), bool, bool) ()
#17 0x000000010b5ca024 in ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, bool, ImageLoader::RPathChain const&, char const*) ()
#18 0x000000010b5c1c86 in dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&, unsigned int) ()
#19 0x000000010b5c5f88 in dlopen_internal ()
#20 0x00007fff5198a9ed in dlopen ()
#21 0x00007fff50b1484a in imp_implementationWithBlock ()
#22 0x000000010b6635df in _swapMethods ()
#23 0x000000010b664b13 in _willInitializeClass ()
#24 0x00007fff50b021d4 in _objc_addWillInitializeClassFunc ()
#25 0x000000010b664ae1 in ___enumerateClasses_block_invoke ()
#26 0x00007fff519477b9 in _dispatch_client_callout ()
#27 0x00007fff519489e5 in _dispatch_once_callout ()
#28 0x000000010b663216 in _enumerateClasses ()
#29 0x000000010b662f4c in ___AllocationsSetup_block_invoke_2 ()
#30 0x00007fff519477b9 in _dispatch_client_callout ()
#31 0x00007fff519489e5 in _dispatch_once_callout ()
#32 0x000000010b662ec1 in ___AllocationsSetup_block_invoke ()
#33 0x000000010b661d70 in _AllocationsSetup ()
#34 0x000000010b6618dc in __OAInit ()
#35 0x000000010b5d03a7 in ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) ()
#36 0x000000010b5d07b8 in ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) ()
#37 0x000000010b5cb9a2 in ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) ()
#38 0x000000010b5ca7a6 in ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) ()
#39 0x000000010b5ca846 in ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) ()
#40 0x000000010b5bf046 in dyld::initializeMainExecutable() ()
#41 0x000000010b5c30fc in dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) ()
#42 0x000000010b5be1cd in start_sim ()
#43 0x0000000119b62234 in dyld::useSimulatorDyld(int, macho_header const*, char const*, int, char const**, char const**, char const**, unsigned long*, unsigned long*) ()
#44 0x0000000119b600ce in dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) ()
#45 0x0000000119b5b503 in dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) ()
#46 0x0000000119b5b036 in _dyld_start ()


Has anybody seen anything like this?

Replies

I'm seeing this exact behavior with the latest Xcode that was released today, 11.3.1. Have you learned anything these past few months?


The only non-system frameworks I link with are Sentry and a simple one for logging.

I'm not sure if you were able to resolve the issue since. However, the XC 11.4 Beta 3 has the following in the release notes:


Fixed an issue in the iOS 13.4 Simulator runtime where applications wouldn’t launch using the Allocations and Leaks templates. (56543962) (FB7403237)


I haven't tried this myself yet, unfortunately, but will do so in the next hour, and will update my answer.

Hi Alexei_DC,
Thanks for sharing the information.
I'm getting the same issue on XC11.3. May I ask if that XC 11.4 Beta3 fix solves the problem?
Hi chunkai,

Based on our knowledge, this issue should be fixed as of Instruments 11.4. Please let us know if that's not the case for you.

Kacper