I've recently converted to using ARC. However, i'm having a weird crash now, and the crashlogs are really unhelpful. During one of my application initialization processes (getting data from server, parsing it, setting up views), i get a bad_access. This is the error log from the device:
Incident Identifier: 7CE05452-7C5D-424A-8529-AE7B17C9FEBC
CrashReporter Key: b743ede30ce737293cf7444f67bb8a7b590c2fd9
Hardware Model: iPhone3,1
Process: BoreBeta [231]
Path: /var/mobile/Applications/52A15437-459A-4160-95C4-BF5DF5C98C15/BoreBeta.app/BoreBeta
Identifier: BoreBeta
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2011-08-18 14:53:41.800 +0200
OS Version: iPhone OS 5.0 (9A5288d)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x80000004
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 CoreFoundation 0x3758e380 CFRelease + 28
1 CoreFoundation 0x375a93ec -[__NSArrayM dealloc] + 116
2 libobjc.A.dylib 0x30a4e0be _objc_rootRelease + 30
3 libobjc.A.dylib 0x30a4fdb0 objc_release + 32
4 libobjc.A.dylib 0x30a4ee06 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 218
5 libobjc.A.dylib 0x30a4ed22 _objc_autoreleasePoolPop + 6
6 CoreFoundation 0x3759f050 _CFAutoreleasePoolPop + 12
7 Foundation 0x337cd460 -[NSAutoreleasePool release] + 120
8 UIKit 0x33b8d948 _UIApplicationHandleEvent + 6664
9 GraphicsServices 0x30ff8ef4 PurpleEventCallback + 876
10 CoreFoundation 0x3760a9c4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
11 CoreFoundation 0x3760a966 __CFRunLoopDoSource1 + 134
12 CoreFoundation 0x3760958c __CFRunLoopRun + 1364
13 CoreFoundation 0x375ab036 CFRunLoopRunSpecific + 294
14 CoreFoundation 0x375aaefe CFRunLoopRunInMode + 98
15 UIKit 0x33b8b758 -[UIApplication _run] + 544
16 UIKit 0x33b8898a UIApplicationMain + 1074
17 BoreBeta 0x00002d8a main (main.m:14)
18 BoreBeta 0x000027f8 start + 32
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x3140d214 kevent + 24
1 libdispatch.dylib 0x376aaf60 _dispatch_mgr_invoke + 708
2 libdispatch.dylib 0x376aac7e _dispatch_mgr_thread + 30
Etcetera, i believe this is the only helpful part. When i let it crash from running in XCode, i see it crashes in main, and i don't get to see any calltrace, apart from main, UIApplicationMain and CFRelease on top..
In the past, i would look through my code for overreleasing objects, but i doubt this is the case because i'm now using ARC. How do you fix errors like this?
Edit: the code for parsing the data is on a seperate thread using GCD, and that's where my only @autoreleasepool lives.
Also, when running with NSZombieEnabled, i'm getting the NSArrayM release call. Unfortunately, that's the same we read in the crash log, so still no real progress here i'm afraid...
Edit: Ok. Once i fixed all my other memory errors without ARC, i got this error once again. So apparently it's not ARC-related...
Known bug introduced relatively recently.
Fixed in a future release (Note that Xcode 4.2 is under NDA, but llvm-commits is not). The commit message is available here. The commit message is slightly vague, but it should cover the case you are seeing -- if that is not the case upon the next compiler release (or you could build one yourself, if so motivated), please immediately file a bug and post the bug # here.
Have you just recently upgraded to Xcode 4.2 beta 5? That seems to cause some random issues with ARC such as that, we sara very similar crash and had to revert back to 4.2 beta 4.
Look on the Apple developer forums for more detail.
I also get this when failing to return an object in a method that has a return type. When the method exits, it throws up EXC_BAD_ACCESS in objc_release.
User contributions licensed under CC BY-SA 3.0