Answered

Deadlock on +[ICMBridge load]


I’m moving our app from the old AppDelegate to the new SceneDelegate. I’m now seeing this stack trace before my app even gets to run. It seems to be stuck on a lock that never resolves.

 

This is on a test run, is there a way I can disable loading Intercom while running tests?

 

Why on earth is Intercom attempting to load images on a +load, who thought this was a good idea.

 

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP

  * frame #0: 0x0000000115293fa8 libsystem_kernel.dylib`__psynch_mutexwait + 8

    frame #1: 0x00000001155107b0 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 80

    frame #2: 0x000000011550e2f8 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 244

    frame #3: 0x0000000115a74aec Intercom`-[IntercomSDK_PINDiskCache isTTLCache] + 20

    frame #4: 0x0000000115a7cdbc Intercom`-[IntercomSDK_PINCache(PINRemoteImageCaching) diskCacheIsTTLCache] + 32

    frame #5: 0x0000000115a85934 Intercom`-[IntercomSDK_PINRemoteImageManager initWithSessionConfiguration:alternativeRepresentationProvider:imageCache:managerConfiguration:] + 464

    frame #6: 0x0000000115a31bf4 Intercom`__44+[IntercomSDK_ITBImageLoader longTermLoader]_block_invoke + 28

    frame #7: 0x0000000180171978 libdispatch.dylib`_dispatch_client_callout + 16

    frame #8: 0x00000001801731b0 libdispatch.dylib`_dispatch_once_callout + 28

    frame #9: 0x0000000115a31bd4 Intercom`+[IntercomSDK_ITBImageLoader longTermLoader] + 60

    frame #10: 0x0000000115bd0a48 Intercom`IntercomSDKPrivate.HomeHeaderContent.init(coder: __C.NSCoder) -> Swift.Optional<IntercomSDKPrivate.HomeHeaderContent> + 536

    frame #11: 0x0000000115bd0d20 Intercom`@objc IntercomSDKPrivate.HomeHeaderContent.init(coder: __C.NSCoder) -> Swift.Optional<IntercomSDKPrivate.HomeHeaderContent> + 28

    frame #12: 0x0000000180d763cc Foundation`_decodeObjectBinary + 2188

    frame #13: 0x0000000180d75210 Foundation`_decodeObject + 180

    frame #14: 0x0000000180d750e0 Foundation`-[NSKeyedUnarchiver decodeObjectForKey:] + 164

    frame #15: 0x0000000180d75494 Foundation`-[NSKeyedUnarchiver decodeObjectOfClasses:forKey:] + 324

    frame #16: 0x00000001808e2bcc Foundation`__C.NSCoder.decodeObject<τ_0_0 where τ_0_0: __C.NSObject, τ_0_0: __C.NSCoding>(of: τ_0_0.Type, forKey: Swift.String) -> Swift.Optional<τ_0_0> + 80

    frame #17: 0x0000000115c77328 Intercom`IntercomSDKPrivate.HomeHeader.init(coder: __C.NSCoder) -> Swift.Optional<IntercomSDKPrivate.HomeHeader> + 152

    frame #18: 0x0000000115c77434 Intercom`@objc IntercomSDKPrivate.HomeHeader.init(coder: __C.NSCoder) -> Swift.Optional<IntercomSDKPrivate.HomeHeader> + 28

    frame #19: 0x0000000180d763cc Foundation`_decodeObjectBinary + 2188

    frame #20: 0x0000000180d75210 Foundation`_decodeObject + 180

    frame #21: 0x0000000180d750e0 Foundation`-[NSKeyedUnarchiver decodeObjectForKey:] + 164

    frame #22: 0x0000000180d75494 Foundation`-[NSKeyedUnarchiver decodeObjectOfClasses:forKey:] + 324

    frame #23: 0x00000001808e2bcc Foundation`__C.NSCoder.decodeObject<τ_0_0 where τ_0_0: __C.NSObject, τ_0_0: __C.NSCoding>(of: τ_0_0.Type, forKey: Swift.String) -> Swift.Optional<τ_0_0> + 80

    frame #24: 0x0000000115cc2ae4 Intercom`IntercomSDKPrivate.HomeConfig.init(coder: __C.NSCoder) -> Swift.Optional<IntercomSDKPrivate.HomeConfig> + 92

    frame #25: 0x0000000115cc2bc4 Intercom`@objc IntercomSDKPrivate.HomeConfig.init(coder: __C.NSCoder) -> Swift.Optional<IntercomSDKPrivate.HomeConfig> + 28

    frame #26: 0x0000000180d763cc Foundation`_decodeObjectBinary + 2188

    frame #27: 0x0000000180d75210 Foundation`_decodeObject + 180

    frame #28: 0x0000000180d750e0 Foundation`-[NSKeyedUnarchiver decodeObjectForKey:] + 164

    frame #29: 0x0000000180d75494 Foundation`-[NSKeyedUnarchiver decodeObjectOfClasses:forKey:] + 324

    frame #30: 0x00000001808e2bcc Foundation`__C.NSCoder.decodeObject<τ_0_0 where τ_0_0: __C.NSObject, τ_0_0: __C.NSCoding>(of: τ_0_0.Type, forKey: Swift.String) -> Swift.Optional<τ_0_0> + 80

    frame #31: 0x0000000115c49570 Intercom`IntercomSDKPrivate.ConfigModules.init(coder: __C.NSCoder) -> Swift.Optional<IntercomSDKPrivate.ConfigModules> + 88

    frame #32: 0x0000000115c49654 Intercom`@objc IntercomSDKPrivate.ConfigModules.init(coder: __C.NSCoder) -> Swift.Optional<IntercomSDKPrivate.ConfigModules> + 28

    frame #33: 0x0000000180d763cc Foundation`_decodeObjectBinary + 2188

    frame #34: 0x0000000180d75210 Foundation`_decodeObject + 180

    frame #35: 0x0000000180d750e0 Foundation`-[NSKeyedUnarchiver decodeObjectForKey:] + 164

    frame #36: 0x0000000180d75494 Foundation`-[NSKeyedUnarchiver decodeObjectOfClasses:forKey:] + 324

    frame #37: 0x0000000115bb6fac Intercom`-[ICMConfig initWithCoder:] + 2856

    frame #38: 0x0000000180d763cc Foundation`_decodeObjectBinary + 2188

    frame #39: 0x0000000180d75210 Foundation`_decodeObject + 180

    frame #40: 0x0000000180d750e0 Foundation`-[NSKeyedUnarchiver decodeObjectForKey:] + 164

    frame #41: 0x0000000180d75494 Foundation`-[NSKeyedUnarchiver decodeObjectOfClasses:forKey:] + 324

    frame #42: 0x0000000180ce98d8 Foundation`-[NSCoder __tryDecodeObjectForKey:error:decodeBlock:] + 88

    frame #43: 0x0000000180cea778 Foundation`-[NSCoder decodeTopLevelObjectOfClasses:forKey:error:] + 96

    frame #44: 0x0000000180d732ec Foundation`+[NSKeyedUnarchiver unarchivedObjectOfClasses:fromData:error:] + 96

    frame #45: 0x0000000180d73034 Foundation`+[NSKeyedUnarchiver unarchivedObjectOfClass:fromData:error:] + 100

    frame #46: 0x0000000115b7967c Intercom`+[ICMPersistenceProxy unarchiveObject:withFile:] + 140

    frame #47: 0x0000000115bb982c Intercom`+[ICMConfig configFromDisk] + 88

    frame #48: 0x0000000115bb9788 Intercom`__25+[ICMConfig sharedConfig]_block_invoke + 20

    frame #49: 0x0000000180171978 libdispatch.dylib`_dispatch_client_callout + 16

    frame #50: 0x00000001801731b0 libdispatch.dylib`_dispatch_once_callout + 28

    frame #51: 0x0000000115bb9770 Intercom`+[ICMConfig sharedConfig] + 112

    frame #52: 0x0000000115c3b5a4 Intercom`IntercomSDKPrivate.IntercomColors.init() -> IntercomSDKPrivate.IntercomColors + 56

    frame #53: 0x0000000115c3b6a4 Intercom`@objc IntercomSDKPrivate.IntercomColors.init() -> IntercomSDKPrivate.IntercomColors + 20

    frame #54: 0x0000000115c3b51c Intercom`one-time initialization function for shared + 28

    frame #55: 0x0000000180171978 libdispatch.dylib`_dispatch_client_callout + 16

    frame #56: 0x00000001801731b0 libdispatch.dylib`_dispatch_once_callout + 28

    frame #57: 0x0000000115c3b568 Intercom`@objc static IntercomSDKPrivate.IntercomColors.shared.getter : IntercomSDKPrivate.IntercomColors + 60

    frame #58: 0x0000000115ba0de4 Intercom`+[ICMAppearanceReset resetAppearanceWithin:] + 1720

    frame #59: 0x0000000115b575d4 Intercom`-[ICMPresentationManager init] + 212

    frame #60: 0x0000000115b57454 Intercom`__40+[ICMPresentationManager sharedInstance]_block_invoke + 20

    frame #61: 0x0000000180171978 libdispatch.dylib`_dispatch_client_callout + 16

    frame #62: 0x00000001801731b0 libdispatch.dylib`_dispatch_once_callout + 28

    frame #63: 0x0000000115b5743c Intercom`+[ICMPresentationManager sharedInstance] + 60

    frame #64: 0x0000000115b574ac Intercom`+[ICMPresentationManager observeSceneWillEnterForeground] + 64

    frame #65: 0x0000000115b54cac Intercom`+[ICMBridge load] + 32

    frame #66: 0x000000018006eef0 libobjc.A.dylib`load_images + 664

    frame #67: 0x0000000114a07d38 dyld_sim`dyld4::RuntimeState::notifyObjCInit(dyld4::Loader const*) + 176

    frame #68: 0x0000000114a0d390 dyld_sim`dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 204

    frame #69: 0x0000000114a0d340 dyld_sim`dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 124

    frame #70: 0x0000000114a10120 dyld_sim`dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const::$_1::operator()() const + 92

    frame #71: 0x0000000114a0d4f0 dyld_sim`dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const + 264

    frame #72: 0x0000000114a1fb98 dyld_sim`dyld4::APIs::dlopen_from(char const*, int, void*) + 1256

    frame #73: 0x00000001803d5e78 CoreFoundation`_CFBundleDlfcnLoadBundle + 188

    frame #74: 0x00000001803a24c4 CoreFoundation`_CFBundleLoadExecutableAndReturnError + 316

    frame #75: 0x0000000180cdcc0c Foundation`-[NSBundle loadAndReturnError:] + 304

    frame #76: 0x00000001144a2d74 libXCTestBundleInject.dylib`__XCTestBundleInject + 576

    frame #77: 0x0000000114a100a8 dyld_sim`invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const::$_0::operator()() const + 152

    frame #78: 0x0000000114a33a84 dyld_sim`invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 164

    frame #79: 0x0000000114a2b79c dyld_sim`invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 488

    frame #80: 0x0000000114a2a470 dyld_sim`dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 284

    frame #81: 0x0000000114a2a77c dyld_sim`dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 164

    frame #82: 0x0000000114a2ce64 dyld_sim`dyld3::MachOFile::forEachInitializerPointerSection(Diagnostics&, void (unsigned int, unsigned int, bool&) block_pointer) const + 132

    frame #83: 0x0000000114a337a4 dyld_sim`dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 324

    frame #84: 0x0000000114a0d068 dyld_sim`dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 384

    frame #85: 0x0000000114a12680 dyld_sim`dyld4::JustInTimeLoader::runInitializers(dyld4::RuntimeState&) const + 32

    frame #86: 0x0000000114a0d39c dyld_sim`dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 216

    frame #87: 0x0000000114a10120 dyld_sim`dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const::$_1::operator()() const + 92

    frame #88: 0x0000000114a0d4f0 dyld_sim`dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const + 264

    frame #89: 0x0000000114a23ce4 dyld_sim`dyld4::APIs::runAllInitializersForMain() + 268

    frame #90: 0x00000001149fdfe8 dyld_sim`dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 2140

    frame #91: 0x00000001149fd398 dyld_sim`_dyld_sim_prepare + 920

    frame #92: 0x00000001145139f8 dyld`dyld4::prepareSim(dyld4::RuntimeState&, char const*) + 1276

    frame #93: 0x000000011451245c dyld`dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 308

    frame #94: 0x0000000114511edc dyld`start + 1844

icon

Best answer by Sergio Campama 16 May 2024, 21:23

View original

4 replies

It looks like the swizzle for sceneWillEnterForeground was the culprit, was able to work around it, but would be great if this could be optional. Why do you even need to listen to that event, and please make sure to prevent the running of code when loading the config from disk. Why do you even need to load a config from disk during load time before main even runs

 A deadlock on ICMBridge load can occur due to conflicting resource access by multiple threads or processes.  dish network customer support number  This often happens when two processes are waiting for each other to release resources, resulting in a deadlock situation where neither can proceed. To resolve this, analyze the code to identify and adjust resource locking mechanisms, ensuring proper synchronization to prevent deadlocks during ICMBridge load operations.    
 

Thanks brandon3, but please refrain from ChatGPT style answers since it doesn’t know about the context the question comes in. In this case, the Intercom SDK is closed source, so developers don’t have access to see what the code is actually doing.

Userlevel 2
Badge +3

Hi @Sergio Campama ! Ebenezer here from Engineering Support👋.

Thanks for bringing this to our attention.

I’ll inform the team about this and see what can be done to improve this.🙏

Reply