EXC_BAD_ACCESS, but not when using breakpoints

女生的网名这么多〃 提交于 2019-12-11 06:19:19

问题


I am getting a crash on my app. It's occurring on dismissModalViewControllerAnimated: message, but... if I set a breakpoint on the NSLog, and step over, it goes through with problem, the EXC_BAD_ACCESS code is 2 and address 0x4:

Thread 1: EXC_BAD_ACCESS(code=2, address=0x4)

I've never had something work with breakpoints and EXC_BAD_ACCESS without them, any ideas?

Please note that my appController is fine. (not released anywhere).

if (appController.modalViewController) {
    NSLog(@"==== RETAIN COUNT ====> %d", appController.modalViewController.retainCount);

    [appController.modalViewController dismissModalViewControllerAnimated:NO];
}

Retain count logs to 1

This also ONLY happens for iOS 4.2 and my app is running on iPad only


回答1:


retainCount is useless. Don't call it.

If you have a crash, you have a backtrace. Please post it.


I've never had something work with breakpoints and EXC_BAD_ACCESS without them, any ideas?

Generally indicates a race condition; your code is dependent on thread A finishing or not finishing something before thread B hits some particular state. Need the backtrace.



来源:https://stackoverflow.com/questions/11569241/exc-bad-access-but-not-when-using-breakpoints

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!