我的僵尸已经超出了我的深度。 findMatchForRequest:
不足以实现一致的匹配,因此使用 [addPlayersToMatch:matchRequest:completionHandler:]
,其中可能崩溃:
-[__NSMallocBlock__ intValue]: unrecognized selector sent to instance
-[CFString retain]: message sent to deallocated instance // NSZombieEnabled
以下是 整个'最低工作示例'项目(on Dropbox),它迟早会崩溃。
@implementation GameCenterHelper { GKMatch* _currentMatch; }
+ (GameCenterHelper *)sharedInstance {
static GameCenterHelper* sharedHelper;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^ {
sharedHelper = [GameCenterHelper new];
});
return sharedHelper;
}
- (void)authenticateLocalPlayer {
[GKLocalPlayer localPlayer].authenticateHandler = ^(UIViewController *loginViewController, NSError *error) {
[self findMatch];
};
}
- (void)findMatch {
GKMatchRequest *request = [GKMatchRequest new];
request.minPlayers = 2;
request.maxPlayers = 4;
[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) {
_currentMatch = match;
_currentMatch.delegate = self;
}];
}
- (void)addPlayersToMatch {
GKMatchRequest *request = [GKMatchRequest new];
request.minPlayers = 2;
request.maxPlayers = 4;
[[GKMatchmaker sharedMatchmaker] addPlayersToMatch:_currentMatch matchRequest:request completionHandler:nil];
}
- (void)match:(GKMatch *)match player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state {
[self addPlayersToMatch];
}
@end
我是否遗漏了块内存管理的基本内容?以上内容被调用:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[GameCenterHelper sharedInstance] authenticateLocalPlayer];
return YES;
}
此处没有错误处理,必须在iTunesConnect上创建一个模型应用程序来体验崩溃,否则不会返回GKMatch
。我还确保Xcode
和iTunesConnect之间的捆绑版本一致,即1.0
vs 1.0.0
。
Zombie陷入Instruments
:
从上面Instruments
,Event Type
,Malloc
看到的每个Release
的{{1}}堆叠跟踪:
Zombie
1的 Malloc
:
RefCt
<{> 0 libsystem_malloc.dylib malloc_zone_malloc
1 CoreFoundation _CFRuntimeCreateInstance
2 CoreFoundation __CFStringCreateImmutableFunnel3
3 CoreFoundation CFStringCreateCopy
4 CoreFoundation _CFStringCreateWithFormatAndArgumentsAux
5 Foundation -[NSPlaceholderString initWithFormat:locale:arguments:]
6 Foundation -[NSString initWithFormat:]
7 GameKitServices -[GKConnectionInternal connectParticipantsWithConnectionData:withSessionInfo:]
8 GameCenterFoundation -[GKMatch connectToPeersWithDictionaries:version:sessionToken:cdxTicket:]
9 GameCenterFoundation __104-[GKMatchmaker matchWithRequest:currentMatch:currentPlayerIDs:serverHosted:rematchID:completionHandler:]_block_invoke_2
10 CoreFoundation __invoking___
11 CoreFoundation -[NSInvocation invoke]
12 GameCenterFoundation -[NSInvocation(GKProxyHelpers) _gkInvokeOnce]
13 GameCenterFoundation __53-[GKDaemonProxy connection:handleInvocation:isReply:]_block_invoke
14 libdispatch.dylib _dispatch_call_block_and_release
15 libdispatch.dylib _dispatch_client_callout
16 libdispatch.dylib _dispatch_main_queue_callback_4CF
17 CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
18 CoreFoundation __CFRunLoopRun
19 CoreFoundation CFRunLoopRunSpecific
20 CoreFoundation CFRunLoopRunInMode
21 GraphicsServices GSEventRunModal
22 UIKit UIApplicationMain
23 GameCenterBug main /Volumes/Lion2/Developer/Objective-C/GameCenterBug/GameCenterBug/main.m:7
24 libdyld.dylib start
Release
0:
RefCt
在 0 CoreFoundation -[__NSCFString release]
1 GameKitServices -[GKConnectionInternal connectParticipantsWithConnectionData:withSessionInfo:]
2 GameCenterFoundation -[GKMatch connectToPeersWithDictionaries:version:sessionToken:cdxTicket:]
3 GameCenterFoundation __104-[GKMatchmaker matchWithRequest:currentMatch:currentPlayerIDs:serverHosted:rematchID:completionHandler:]_block_invoke_2
4 CoreFoundation __invoking___
5 CoreFoundation -[NSInvocation invoke]
6 GameCenterFoundation -[NSInvocation(GKProxyHelpers) _gkInvokeOnce]
7 GameCenterFoundation __53-[GKDaemonProxy connection:handleInvocation:isReply:]_block_invoke
8 libdispatch.dylib _dispatch_call_block_and_release
9 libdispatch.dylib _dispatch_client_callout
10 libdispatch.dylib _dispatch_main_queue_callback_4CF
11 CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
12 CoreFoundation __CFRunLoopRun
13 CoreFoundation CFRunLoopRunSpecific
14 CoreFoundation CFRunLoopRunInMode
15 GraphicsServices GSEventRunModal
16 UIKit UIApplicationMain
17 GameCenterBug main /Volumes/Lion2/Developer/Objective-C/GameCenterBug/GameCenterBug/main.m:7
18 libdyld.dylib start
-1:的 Zombie
RefCt
相同的,ARC之前的问题(有一个可疑的答案):-[CFString retain]: message sent to deallocated instance 0x215076c0
相关:
答案 0 :(得分:0)
几个小时前,苹果公司表示该漏洞已得到修复,修复程序将在下一个iOS版本之一。