简体   繁体   中英

Debugging a EXEC_BAD_ACCESS on iOS

I have a very strange EXEC_BAD_ACCESS error, the error happens on application start. No breakpoint or NSLog was reached it cancels when UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])) get called.

It only crashes on simulator not on the device or with instruments. Zombies give me no informations, when I enable GUARDMALLOC on simulator it doesnt crash. The EXEC_BAD_ACCESS happens always on the same memory address.

I can get following backtrace

#0  0xcd58a2f6 in ?? ()
#1  0x0102b524 in -[UIWindow _commonInit] ()
#2  0x0102b66f in -[UIWindow initWithFrame:] ()
#3  0x0137be58 in -[UIStatusBarWindow initWithFrame:] ()
#4  0x0103c28f in -[UIView init] ()
#5  0x01000a5e in -[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:] ()
#6  0x00ffbe6b in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()
#7  0x0100d315 in -[UIApplication handleEvent:withNewEvent:] ()
#8  0x0100e24b in -[UIApplication sendEvent:] ()
#9  0x00fffcf8 in _UIApplicationHandleEvent ()
#10 0x02fe7df9 in _PurpleEventCallback ()
#11 0x02fe7ad0 in PurpleEventCallback ()
#12 0x022cabf5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#13 0x022ca962 in __CFRunLoopDoSource1 ()
#14 0x022fbbb6 in __CFRunLoopRun ()
#15 0x022faf44 in CFRunLoopRunSpecific ()
#16 0x022fae1b in CFRunLoopRunInMode ()
#17 0x00ffb7da in -[UIApplication _run] ()
#18 0x00ffd65c in UIApplicationMain ()
#19 0x00002ea2 in main (argc=1, argv=0xbffff2a0) at /Users/user/Projects/App/App/main.m:16

When I try to get informations about the memory I get

Cannot access memory at address 0xcd58a2f6

I can resolve it sometimes when I change some code but it happens again when I only create a local variable in some other functions, so I think the problem lays a bit deeper.

I'm a bit confused because didFinishLaunchingWithOptions never get reached when the error occurs, so what sort of influence can have code in my viewcontrollers?

As 3rd party components I use Phonegap 2.1 as a component and Reachability from Apple.

You can add exception breakpoints to get the location of the error. Here is a nice link of tutorial for the same. Hope it works for you.

Link is here.

Assuming it is not an xib issue, you could use atos (address to symbol) debugging to help you find the location of the issue.

A good tutorial on this method is available at http://saveme-dot-txt.blogspot.com/2011/04/using-atos-for-reading-crash-logs.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM