オブジェクトをインスタンス化しようとすると、TyphoonComponentFactory.m でクラッシュが発生します - この行は EXC_BAD_ACCESS でクラッシュします:
279:[pool setObject:instance forKey:definition.key];
または時々これ:
276:id instance = [pool objectForKey:definition.key];
すべての変数 (プール、インスタンス、定義) は、デバッガーでクラッシュ時に正しく表示されます。プログラムの実行の早い段階で (ただし、それほど前ではなく、つまり同じ実行ループ)、TyphoonComponentFactory をセットアップし、それをデフォルトのファクトリにしました。これを引き起こしている可能性のあるものはありますか?ファクトリの作成が発信者にとって遅すぎるという漠然とした理論がありましたが...かなり弱いです。
台風バージョン 1.8.2。アセンブリは次のとおりです。
#import "EndpointQueueAssembly.h"
#import "EndpointQueue.h"
#import "URLStorage.h"
#import "EndpointHTTPMethods.h"
#import "EndpointURLStrings.h"
#import "HTTPRequestOperationFactory.h"
#import "Services.h"
#import "ChatImageCheck.h"
@implementation EndpointQueueAssembly
-(id)endpointQueue
{
return [TyphoonDefinition withClass: [EndpointQueue class] properties:^(TyphoonDefinition *definition) {
[definition setScope:TyphoonScopeSingleton];
}];
}
-(id)urlStorage
{
return [TyphoonDefinition withClass: [URLStorage class]];
}
-(id)endpointHTTPMethods
{
return [TyphoonDefinition withClass: [EndpointHTTPMethods class]];
}
-(id)chatImageCheck
{
return [TyphoonDefinition withClass: [ChatImageCheck class]];
}
-(id)endpointURLStrings
{
return [TyphoonDefinition withClass: [EndpointURLStrings class] properties:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(urlStorage)];
}];
}
-(id)httpRequestOperationFactory
{
return [TyphoonDefinition withClass: [HTTPRequestOperationFactory class] properties:^(TyphoonDefinition* definition) {
[definition injectProperty:@selector(endpointHTTPMethods)];
[definition injectProperty:@selector(endpointURLStrings)];
}];
}
-(id)services
{
return [TyphoonDefinition withClass:[Services class] properties:^(TyphoonDefinition *definition) {
[definition setScope:TyphoonScopeSingleton];
}];
}
@end
276 行目のクラッシュのスタック トレース:
Thread 65, Queue : NSOperationQueue 0x12434e90
#0 0x0473756b in -[__NSDictionaryM objectForKey:] ()
#1 0x0033c2dd in -[TyphoonComponentFactory sharedInstanceForDefinition:fromPool:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Pods/Typhoon/Source/Factory/TyphoonComponentFactory.m:276
#2 0x0033cb34 in -[TyphoonComponentFactory(TyphoonDefinitionRegisterer) objectForDefinition:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Pods/Typhoon/Source/Factory/TyphoonComponentFactory.m:315
#3 0x0033b01d in -[TyphoonComponentFactory componentForKey:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Pods/Typhoon/Source/Factory/TyphoonComponentFactory.m:151
#4 0x046a291d in __invoking___ ()
#5 0x046a282a in -[NSInvocation invoke] ()
#6 0x00335f69 in -[TyphoonBlockComponentFactory forwardInvocation:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Pods/Typhoon/Source/Factory/Block/TyphoonBlockComponentFactory.m:97
#7 0x0469e2da in ___forwarding___ ()
#8 0x0469e0ee in __forwarding_prep_0___ ()
#9 0x00022647 in +[CascadeItemRenderOperation isCurrentProfileWithDictionary:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Shared/CascadeItemRenderOperation.m:166
#10 0x00022d3b in +[CascadeItemRenderOperation countOfUnreadChatsWithDictionary:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Shared/CascadeItemRenderOperation.m:205
#11 0x00021c7c in +[CascadeItemRenderOperation renderWithDictionary:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Shared/CascadeItemRenderOperation.m:79
#12 0x001002b2 in -[GrindrGridViewPreRenderOperation main] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Grindr/GrindrGridViewPreRenderOperation.m:38
#13 0x02d0dc79 in -[__NSOperationInternal _start:] ()
#14 0x02c8a9c8 in -[NSOperation start] ()
#15 0x02d0ff44 in __NSOQSchedule_f ()
#16 0x04d164d0 in _dispatch_client_callout ()
#17 0x04d02fe0 in _dispatch_async_redirect_invoke ()
#18 0x04d164d0 in _dispatch_client_callout ()
#19 0x04d04eb7 in _dispatch_root_queue_drain ()
#20 0x04d05127 in _dispatch_worker_thread2 ()
#21 0x05045dab in _pthread_wqthread ()
関連オブジェクトの値:
self: レジストリで利用可能なすべての関連オブジェクトを含む TyphoonBlockComponentFactory。定義: "定義: class='AuthenticationDetails', key='authenticationDetails'" プール: NSDictionary、0 のキーと値のペア インスタンス: id、初期化されていないポインター。
当時のメイン スレッドのスタックは次のとおりです。Typhoon の参照も含まれています。
Thread 1, Queue : com.apple.main-thread
#0 0x05081802 in __psynch_mutexwait ()
#1 0x05047945 in _pthread_mutex_lock ()
#2 0x050477ac in pthread_mutex_lock ()
#3 0x0443a498 in objc_sync_enter ()
#4 0x0033c288 in -[TyphoonComponentFactory sharedInstanceForDefinition:fromPool:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Pods/Typhoon/Source/Factory/TyphoonComponentFactory.m:275
#5 0x0033cb34 in -[TyphoonComponentFactory(TyphoonDefinitionRegisterer) objectForDefinition:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Pods/Typhoon/Source/Factory/TyphoonComponentFactory.m:315
#6 0x0033b01d in -[TyphoonComponentFactory componentForKey:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Pods/Typhoon/Source/Factory/TyphoonComponentFactory.m:151
#7 0x046a291d in __invoking___ ()
#8 0x046a282a in -[NSInvocation invoke] ()
#9 0x00335f69 in -[TyphoonBlockComponentFactory forwardInvocation:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Pods/Typhoon/Source/Factory/Block/TyphoonBlockComponentFactory.m:97
#10 0x0469e2da in ___forwarding___ ()
#11 0x0469e0ee in __forwarding_prep_0___ ()
#12 0x000735e7 in -[Profile(Custom) isMe] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Utils/Profile+Custom.m:74
#13 0x0022a0eb in -[Profile(GrindrGridViewHash) grindrGridViewHash] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Shared/Profile+GrindrGridViewHash.m:84
#14 0x000ff3ed in -[GrindrGridViewPreRenderCache preRenderManagedObjectsForBackgroundExecution:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Grindr/GrindrGridViewPreRenderCache.m:105
#15 0x000ff174 in -[GrindrGridViewPreRenderCache preRenderManagedObjects:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Grindr/GrindrGridViewPreRenderCache.m:87
#16 0x00041c8f in -[GrindrGridView endUpdates] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Shared/GrindrGridView.m:825
#17 0x002343d2 in -[CascadeDataSource controllerDidChangeContent:] at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Grindr/CascadeDataSource.m:137
#18 0x0276e347 in -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] ()
#19 0x02d0c049 in __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke ()
#20 0x04709f04 in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#21 0x04661efb in _CFXNotificationPost ()
#22 0x02c45e41 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#23 0x02670a13 in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] ()
#24 0x0270ffaf in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] ()
#25 0x0266beb8 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] ()
#26 0x0266b649 in -[NSManagedObjectContext processPendingChanges] ()
#27 0x0269a4cc in -[NSManagedObjectContext(_NestedContextSupport) _parentProcessSaveRequest:inContext:error:] ()
#28 0x02712a14 in __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke ()
#29 0x02694b81 in internalBlockToNSManagedObjectContextPerform ()
#30 0x04d164d0 in _dispatch_client_callout ()
#31 0x04d05439 in _dispatch_barrier_sync_f_slow_invoke ()
#32 0x04d164d0 in _dispatch_client_callout ()
#33 0x04d04726 in _dispatch_main_queue_callback_4CF ()
#34 0x0471343e in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#35 0x046545cb in __CFRunLoopRun ()
#36 0x046539d3 in CFRunLoopRunSpecific ()
#37 0x046537eb in CFRunLoopRunInMode ()
#38 0x053ee5ee in GSEventRunModal ()
#39 0x053ee42b in GSEventRun ()
#40 0x03513f9b in UIApplicationMain ()
#41 0x0000e704 in main at /Users/nicklocking/Documents/primus-ios/NBFIOSCore/Shared/main.m:18
さらに更新:
Typhoon はデフォルトで TyphoonScopeObjectGraph に設定されているようですが、これは明らかにスレッドセーフではありません。すべての非シングルトンを TyphoonScopePrototype に切り替え、59 行目の TyphoonCallStack -pop でクラッシュが発生するようになりました[_storage removeLastObject]
。ある種の例外のようですが、デバッガーは有用なものを何も吐き出しません。