EXC_BAD_ACCESS in device, not in simulator

不羁岁月 提交于 2021-01-27 06:15:17

问题


I have implemented adwhirl in my project. I have implemented it previously in my projects, so I just incorporated it into my current project from my previous.

- (UIViewController *)viewControllerForPresentingModalView {
{
  return self;
}

I had used this in my previous projects..since my window.rootvviewcontroller was self only. But in my current project there are many screens on which I am showing ads, so I have used:

- (UIViewController *)viewControllerForPresentingModalView {
    {
      return return [[(AppDelegate *)[[UIApplication sharedApplication] delegate] window] rootViewController] ;;
    }

The main problem is the program was crashing, and still is. At first everything was okay: iads test ads loaded up, but it crashed rarely. I soon understand it was because of Admob. It crashed rarely because admob ads were not loaded most of the time.

Now searching for these crashes, I came across a point that since I have made the project in Xcode 4.2 rather than my previous projects Xcode 4.0 there were strong attributes in my window and view controller. I removed it.

Now the problem is in simulator it doesn't crash but it crashes in device.

The error is after I have added adview as a subview and it has - (UIViewController *)viewControllerForPresentingModalView went through this function but before adWhirlDidReceiveAd method.

The actual crash is [GADRequestPrivate spamSignals] EXC_BAD_ACCESS.


回答1:


Below answer has already earned bounty for me :) ..... you can try for your problem...

Link : Getting to the bottom of crash

I found one of the best way to Debug the code for Crash. Follow the link for Debugging technique:

http://www.cocoadev.com/index.pl?DebuggingAutorelease

You need to analyze your Console very carefully to see actually why the Crash occurs. This helped me in almost all of the Code that are without ARC enabled.




回答2:


I recommend you analyze your project and look for memory leaks and zombies. It seems like you are sending a message to a released object which causes the invalid memory access. The zombies detection cannot be run on the device, but you can run it on the simulator. Take a look at Xcode Instruments - Enable NSZombie Detection? Where is it?

Hope it helps.




回答3:


Even if this happens in proprietary Adwhirl code, you can learn a lot by turning on all the debugging flags as specified, for example, in How to break on __NSAutoreleaseNoPool. This answer discusses lots of debugging flags, not just autorelease pool ones.



来源:https://stackoverflow.com/questions/9225412/exc-bad-access-in-device-not-in-simulator

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