xcode编译器问题——参数类型识别错误,EXC_BAD_ACCESS

调试iOS工程的时候发现诡异问题,函数如下:

-(void) getLoadPageCommentAndTopicVid:(long long)vid cid:(long)cid site:(long)site title:(NSString*)title videoUrl:(NSString*)videoUrl more:(BOOL)more commentGetCommpletionBlock:block commentGetFailtureBlock:block{
}

当调用这个函数的时候,出现EXC_BAD_ACCESS;在控制台bt一下:

* thread #1: tid = 0x2503, 0x32b59522 libobjc.A.dylib`objc_retain + 2, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x2)
    frame #0: 0x32b59522 libobjc.A.dylib`objc_retain + 2
    frame #1: 0x32b67b86 libobjc.A.dylib`objc_storeStrong + 22
  * frame #2: 0x0006f978 xxxxxx`-[AppDelegate(self=0x1dd71420, _cmd="getLoadPageCommentAndTopicVid:cid:site:title:videoUrl:more:commentGetCommpletionBlock:commentGetFailtureBlock:", vid=8500161, cid=6, site=0, title=0x00000000, videoUrl=0x0c29a000, more=YES,commentGetCommpletionBlock=<read memory from 0xe13f5a7b failed (0 of 4 bytes read)>, commentGetFailtureBlock=0xc0bf00bc) 

根据栈提示,读取block参数有问题,后来仔细查阅block;发现block定义没有问题。后来一个个参数定位,终于定位到vid参数,site参数的问题。如果site参数传0,可以调用该函数,如果是1(非0)调用出现上面的崩溃。

【推测】:xcode编译器可能把这个int当做指针或者其他类型了,导致后面的参数读取错误。貌似第一个参数是long long会有问题

【解决】:针对vid,site参数。使用NSNumber*代替long long ;NSInteger即可解决

你可能感兴趣的:(memory,exc_bad_access,read,from)