periodic IOS crash, but I do not see any involvement of my app in crash report - ios10.2

About once a week I'm getting a crash like this one. Maybe I'm wrong, but I do not see any involvement of my app ("WayAndSee"). Does anybody have a hint how to proceed?
Attached the crash report (which is very typically for that kind of crash), I just truncated the trailing list of libraries.
Many thanks in advance ...
Incident Identifier: 348BDC52-6574-4EED-A6C7-45E79E696875
CrashReporter Key: f8ac3e1a61b8129920a4ad40aaa56d5536e2ce22
Hardware Model: iPhone6,2
Process: WayAndSee [8286]
Path: /private/var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/WayAndSee
Identifier: Hobrink.WayAndSee
Version: 2487 (0.3.0)
Code Type: ARM (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: Hobrink.WayAndSee [2936]
Date/Time: 2017-04-04 14:28:15.3459 +0200
Launch Time: 2017-04-04 13:05:54.5835 +0200
OS Version: iPhone OS 10.2.1 (14D27)
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x1cedf84c mach_msg_trap + 20
1 CoreFoundation 0x1d7082f9 __CFRunLoopServiceMachPort + 137
2 CoreFoundation 0x1d7065f7 __CFRunLoopRun + 1015
3 CoreFoundation 0x1d655533 CFRunLoopRunSpecific + 487
4 CoreFoundation 0x1d655341 CFRunLoopRunInMode + 105
5 GraphicsServices 0x1ee2cbfd GSEventRunModal + 157
6 UIKit 0x22863e67 -[UIApplication _run] + 575
7 UIKit 0x2285e591 UIApplicationMain + 151
8 WayAndSee 0x000ba890 main (AppDelegateV2a.swift:667)
9 libdyld.dylib 0x1ce1f50b start + 3
Thread 1 name: com.apple.uikit.eventfetch-thread
Thread 1:
0 libsystem_kernel.dylib 0x1cedf84c mach_msg_trap + 20
1 CoreFoundation 0x1d7082f9 __CFRunLoopServiceMachPort + 137
2 CoreFoundation 0x1d7065f7 __CFRunLoopRun + 1015
3. CoreFoundation 0x1d655533 CFRunLoopRunSpecific + 487
4 CoreFoundation 0x1d655341 CFRunLoopRunInMode + 105
5 Foundation 0x1dfaf88b -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 261
6 Foundation 0x1dfce631 -[NSRunLoop(NSRunLoop) runUntilDate:] + 87
7 UIKit 0x2316a2b3 -[UIEventFetcher threadMain] + 129
8 Foundation 0x1e098b11 __NSThread__start__ + 1161
9 libsystem_pthread.dylib 0x1cfa9a27 _pthread_body + 217
10 libsystem_pthread.dylib 0x1cfa994d _pthread_start + 235
11 libsystem_pthread.dylib 0x1cfa749c thread_start + 8
Thread 2 name: NetworkLoad
Thread 2:
0 libsystem_kernel.dylib 0x1cedf84c mach_msg_trap + 20
1 CoreFoundation 0x1d7082f9 __CFRunLoopServiceMachPort + 137
2 CoreFoundation 0x1d7065f7 __CFRunLoopRun + 1015
3 CoreFoundation 0x1d655533 CFRunLoopRunSpecific + 487
4 CoreFoundation 0x1d655341 CFRunLoopRunInMode + 105
5 GeoServices 0x244775ff _runNetworkThread + 475
6 libsystem_pthread.dylib 0x1cfa9a27 _pthread_body + 217
7 libsystem_pthread.dylib 0x1cfa994d _pthread_start + 235
8 libsystem_pthread.dylib 0x1cfa749c thread_start + 8
Thread 3:
0 libsystem_kernel.dylib 0x1cef5744 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1cfa7490 start_wqthread + 8
Thread 4:
0 libsystem_pthread.dylib 0x1cfa7488 start_wqthread + 0
Thread 5:
0 libsystem_pthread.dylib 0x1cfa7488 start_wqthread + 0
Thread 6:
0 libsystem_pthread.dylib 0x1cfa7488 start_wqthread + 0
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x10004005 r1: 0x07000806 r2: 0x00000000 r3: 0x00000c00
r4: 0x00002403 r5: 0xffffffff r6: 0x00000000 r7: 0x0042adb4
r8: 0x00000c00 r9: 0x00002403 r10: 0x07000806 r11: 0x00000000
ip: 0xffffffe1 sp: 0x0042ad78 lr: 0x1cedf63f pc: 0x1cedf84c
cpsr: 0x60000010
Binary Images:
0xb0000 - 0x177fff WayAndSee armv7 <7506039ae577329ab9868e3122d84f5f> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/WayAndSee
0x25c000 - 0x267fff libswiftCoreData.dylib armv7s <3022e21a184d3e6c93bac1ad7b18be30> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCoreData.dylib
0x27c000 - 0x28bfff libswiftCoreGraphics.dylib armv7s <4415e467b6df386591e646e7a2978da6> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCoreGraphics.dylib
0x2a8000 - 0x2affff libswiftCoreImage.dylib armv7s <9bbbe5b77fdd3551921ca7ec1a98ae38> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCoreImage.dylib
0x2c0000 - 0x2ebfff dyld armv7s <898b6b42ae3b3ffb8de9a96b7071f49d> /usr/lib/dyld
0x42c000 - 0x6abfff libswiftCore.dylib armv7s <b760608c5d35390099731eedb8821bc0> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCore.dylib
....

as I got several questions about my progress on this issue, I decided to wrote an answer by myself. Maybe this could be helpful for others.
The crash reports has one important line: "Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d" -> the SPRINGBOARD tried to start the app in background... and "0x8dadf00d" could be read as "ate bad food" (look around here on StackOverflow, numerous explanation for that code)
The root cause of that issue is simply the launchtime. It's too long for a start in background. There is a time limit for background start of about 5 to 7 seconds. Launch in foreground has an allowed time window of about 20 sec.
This time limit includes the time BEFORE main() and AFTER main() until the app its settled and ready to receive the launching event. Each launch of an app in background is caused by a launching event (location, file transfer etc.)
To get an idea how to analyze the time before main() I suggest to watch the video "Optimizing App Startup Time", Session 406, WWDC 2016. They explain in detail what happen BEFORE main and how to analyze and measure it. They describe several environment variables (set in "arguments" section of the scheme) which produce helpful logs.
"main()", yes, I learned it during this examination. Swift allows it to have a main(). It's even a possibility to execute statements outside of a function, class, struct ... There is no real need for that in swift. But as I wanted to measure the launch time after main, I wrote this simple main.swift file to do so.
//
// main.swift
// ...
//
// Created by Hartwig Hopfenzitz on 31.05.17.
// Copyright © 2017 Hopfenzitz. All rights reserved.
//
import Foundation
import UIKit
// very first statement after load.. the current time
let WaysStartTime = CFAbsoluteTimeGetCurrent()
// build the parameters for the call to UIApplicationMain()
let argc = CommandLine.argc
let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(to: UnsafeMutablePointer<Int8>.self, capacity: Int(CommandLine.argc))
// start the main loop
UIApplicationMain(argc, argv, nil, NSStringFromClass(AppDelegate.self))
As you can see: In the very first statement I take the time. With this I can measure the time difference to the time when the app is up and running.
However: If you want to use a main() in your swift project, you have to comment out or delete the statement "#UIApplicationMain" in AppDelegate.swift. This statement "simulates" the main() function, so it would be redundant.
And yes, it is worth to start measure on main(). I did also tests with time measuring starting on "willFinishLaunchingWithOptions:". On my usual test device, an iPhone 5s (real test device, not a simulator), the difference is about 0.4 sec. I'm sure that time depends on the app and how it is structured, so I suggest to measure it from main().
OK, and as always: "if you measure, you are able to manage".
The usual root cause for slow launch times is an overloaded main thread. This main thread is the most important working horse of each app. It burdens the event loop and the UI.
So my first step was to shift as much work as possible away from main threat by using GCD (Grand Central Dispatch). GCD is quite easy to use and gives you a lot of options to fine tune the workload of the several threads. There are several videos on WWDC about GCD, my personal favorite one is the "Building Responsive and Efficient Apps with GCD", Session 718, WWDC 2015.
However, by this I reduced the number of crashes drastically, BUT.... there was still crashes ...
My initial screen is so complex, using a lot of autolayout and autosizing etc.. It simply sometimes took to long to finish the rendering before the time limit crashes the app. If I understand everything right, IOS wants to have the first screen up and running, to consider a successful launch.
Well, the magic words are "the first screen".
I love my Main.storyboard, very nice looking and highly adaptive. So I didn't want to strip it down. Luckily I found this blog http://timdietrich.me/blog/swift-multiple-storyboards/. It describes the steps necessary to work with several storyboards in an swift/xcode project. There are several others to find on the internet, but this one is quite easy to read and understand.
So I created a storyboard called "Start.storyboard". This storyboard is very simple, just a copy of the Launchscreen.storyboard. And I used this as "the first screen".
I created this class for the ViewController of this start screen, which does nothing else than launching my Main.Storyboard.
//
// StartViewController.swift
// ...
//
// Created by Hartwig Hopfenzitz on 02.06.17.
// Copyright © 2017 Hopfenzitz. All rights reserved.
//
import UIKit
class StartViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// Create instance of our main storyboard
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
// Create the instance of main's initial view controller.
let mainController = mainStoryboard.instantiateViewController(withIdentifier: "WaysViewController") as UIViewController
// Make sure it will start on the main thread
DispatchQueue.main.async(execute: {
// present it .. and never come back
mainController.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
mainController.modalPresentationStyle = .fullScreen // Display on top of current UIView
self.present(mainController, animated: true, completion: nil)
})
}
}
In Info.plist you will find the key "Main storyboard file base name". This key tells which story board is the one with the initial screen. So in my example you have to change the value from "Main" to "Start", as the new initial storyboard is called "Start.storyboard".
And Voilá: the first screen starts almost immediately and IOS is very happy about the launch time. The user doesn't recognize it.
OK that's how I got rid of this crashes... maybe it will help others...
Happy coding ;-)

Related

Large amount of crashes on core data managedobjectmodel

Using Fabrics crash analytics or "Crashlytics" I am getting a large amount of crashes (I assume BAD_ACCESS) from the following method/property :
lazy var managedObjectModel: NSManagedObjectModel = {
// The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
var modelURL = NSBundle.mainBundle().URLForResource("<app_name>", withExtension: "momd")
return NSManagedObjectModel(contentsOfURL: modelURL!)!
}()
By large amount I mean 275 crashes for 150 users in just one day. It is working fine on most devices but I did have the issue once with my simulator and I reset the contents and restarted my machine and the error went away.
I am hoping there is a better solution than having to tell people who are calling our tech support.
Returned by fabric
Crashed: com.apple.main-thread
0 <app_name> 0x100082f9c specialized AppDelegate.(persistentStoreCoordinator.getter).(closure #1) (AppDelegate.swift:314)
1 <app_name> 0x10007e678 AppDelegate.saveContext() -> () (AppDelegate.swift:340)
2 <app_name> 0x10007e014 #objc AppDelegate.applicationWillTerminate(UIApplication) -> () (AppDelegate.swift)
3 UIKit 0x1949f0d48 -[UIApplication _terminateWithStatus:] + 244
4 UIKit 0x194bef268 __102-[UIApplication _handleApplicationDeactivationWithScene:shouldForceExit:transitionContext:completion:]_block_invoke.2093 + 792
5 UIKit 0x194bf2a18 _runAfterCACommitDeferredBlocks + 292
6 UIKit 0x194be4ab4 _cleanUpAfterCAFlushAndRunDeferredBlocks + 528
7 UIKit 0x194958724 _afterCACommitHandler + 132
8 CoreFoundation 0x18e7e49a0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
9 CoreFoundation 0x18e7e2628 __CFRunLoopDoObservers + 372
10 CoreFoundation 0x18e7e2a74 __CFRunLoopRun + 956
11 CoreFoundation 0x18e712d94 CFRunLoopRunSpecific + 424
12 GraphicsServices 0x19017c074 GSEventRunModal + 100
13 UIKit 0x1949cb130 UIApplicationMain + 208
14 <app_name> 0x100069940 main (AppDelegate.swift:43)
15 libdyld.dylib 0x18d72159c start + 4
Has anyone else run into this issue? We are using Swift 2.3 currently converting to Swift 3.1.
The function is called when applicationWillTerminate() is called. The modelURL is nil.
I also observed similar situation in my app. I once or twice had this error on simulator.
According to my observations it's happens when user swipes app from App Switcher (and removes it from memory). My guess is that Bundle.main becomes unavailable earlier and app cannot finish something.
I didn't have any contact from users that observed that. It looks like that they can't observe this because they just killed the app. So it's probably harmless (even if annoying).

iOS 6 Maps occasional Crash

I'm getting occasionally crash with iOS 6 MapKit. Can't really reproduce it. What can cause this?
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000044
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 IMGSGX543GLDriver 0x38f231b4 sgxTextureGetImageRowBytes(GLDTextureRec*, unsigned int, unsigned int) + 8
1 IMGSGX543GLDriver 0x38f23160 CalculateChunkPlaneSizes(GLDTextureRec*, int, unsigned int*, unsigned int*, unsigned int*, unsigned int*) + 104
2 IMGSGX543GLDriver 0x38f25906 sgxConfigureTexturePrivate(GLDTextureRec*) + 82
3 IMGSGX543GLDriver 0x38f24584 glrUpdateTexture + 616
4 libGPUSupportMercury.dylib 0x342c76b6 gldLoadFramebuffer + 102
5 GLEngine 0x31b50e52 gleUpdateDrawFramebufferState + 178
6 GLEngine 0x31b52556 gleDoDrawDispatchCoreES2 + 126
7 GLEngine 0x31aedbc0 gleDrawArraysOrElements_Entries_Body + 140
8 GLEngine 0x31aea5ec glDrawArrays_ES2Exec + 160
9 VectorKit 0x3780dcd6 -[VKSkyModel drawScene:withContext:] + 326
10 VectorKit 0x377e76d6 -[VKModelObject recursiveDrawScene:whenReadyWithContext:] + 118
11 VectorKit 0x377621ea -[VKMapModel recursiveDrawScene:withContext:] + 278
12 VectorKit 0x37762096 -[VKModelObject recursiveDrawScene:withContext:] + 186
13 VectorKit 0x3775d4da -[VKScreenCanvas onTimerFired:] + 1014
14 VectorKit 0x3775b548 -[VKMapCanvas onTimerFired:] + 500
15 VectorKit 0x3775a3d2 -[VKMainLoop displayTimerFired:] + 610
16 QuartzCore 0x3095b06c CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long) + 156
17 QuartzCore 0x3095afc4 CA::Display::IOMFBDisplayLink::callback(__IOMobileFramebuffer*, unsigned long long, unsigned long long, unsigned long long, void*) + 60
18 IOMobileFramebuffer 0x331e4fd4 IOMobileFramebufferVsyncNotifyFunc + 152
19 IOKit 0x36fc4446 IODispatchCalloutFromCFMessage + 190
20 CoreFoundation 0x382a95d8 __CFMachPortPerform + 116
21 CoreFoundation 0x382b4170 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
22 CoreFoundation 0x382b4112 __CFRunLoopDoSource1 + 134
23 CoreFoundation 0x382b2f94 __CFRunLoopRun + 1380
24 CoreFoundation 0x38225eb8 CFRunLoopRunSpecific + 352
25 CoreFoundation 0x38225d44 CFRunLoopRunInMode + 100
26 GraphicsServices 0x3415f2e6 GSEventRunModal + 70
27 UIKit 0x351b72fc UIApplicationMain + 1116
28 MyApp 0x0005d78a main (main.m:14)
29 MyApp 0x0005d744 start + 36
I found this. It may help you fix your problem.
"Issue: An OpenGL ES-based application displays “flashing” or “stale” frames after a call to presentRenderBuffer.
This symptom can occur when an OpenGL ES application calls the EAGL presentRenderbuffer method without first drawing anything. What is seen on screen may contain uninitialized pixels or previously rendered frames. To correct this issue, you should always draw something to your framebuffer before calling presentRenderbuffer. Also note that unless you set the RetainedBackbuffer property on your CAEAGLLayer to enable retained backbuffer mode, the contents of your renderbuffer are not guaranteed to remain valid after a call to presentRenderbuffer".
-Lewis
I actually found the issue with the iOS version. The user was running on iPad 4, iOS 6.1.2, as soon as I upgraded to 6.1.3 the problem went away. Hope this helps someone.
Thanks, Tim
I had this exact issue and it turned out to be a memory pressure related crash. It was consistently crashing for me when the map appeared with a black background instead of any tiles or grid backgrounds like normal on the fourth or fifth time the map was shown. This occurred on iOS 6.0 and 6.1 and beta of 7.0.
My view controller with the map view wasn't being deallocated after it was removed from the Navigation stack and it had a strong reference to the map view which kept it in memory.
After fixing my leak, the problem disappeared.
I just experienced this testing an App on my iPad. It's always run with no problems in simulator and also on the device but just now it crashed at the same point with the same error.
Here's my method - very simple map showing user location and no annotations:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
MKCoordinateSpan span = self.mapView.region.span;
zoomLevel = span.latitudeDelta;
shouldAdjustZoom = NO;
}
Here's the crash log
Incident Identifier: 01AE9C88-1F56-44D4-92A1-C6B5938DEBD4
CrashReporter Key: f372f86613043286b74e70a8d1f9d7b1b5313cf5
Hardware Model: iPad3,4
Process: MyApp [1247]
Path: /var/mobile/Applications/C39AEC49-8DB1-45DE-B175-A6AEC19D533F/MyApp.app/MyApp
Identifier: MyApp
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-07-15 08:25:16.390 +0200
OS Version: iOS 6.1.3 (10B329)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000044
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 IMGSGX554GLDriver 0x32ea6be0 0x32e99000 + 56288
1 IMGSGX554GLDriver 0x32ea6b8e 0x32e99000 + 56206
2 IMGSGX554GLDriver 0x32ea92f2 0x32e99000 + 66290
3 IMGSGX554GLDriver 0x32ea7f44 0x32e99000 + 61252
I ended a whole bunch of apps (mostly kids games) running in the background on the device and relaunched it and it then ran fine. Maybe helps someone pinpoint the exact problem and whether any changes in our Apps can prevent the crash.

Crash on private method of UIAlertView

I'm seeing a strange crash in one of my apps that seems to be coming from a private method on UIAlertView. I've down some searching and found a few other references to this method being involved in crashes such as here, but I'm not convinced that the cause is the same. However to be certain made sure that I always set the UIAlertView delegate to nil whenever the delegate is deallocated.
The stack trace is as follows:
Exception Type: SIGABRT
Exception Codes: #0 at 0x351ce32c
Crashed Thread: 0
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x351ce32c __pthread_kill + 8
1 libsystem_c.dylib 0x370c329f abort + 95
2 eLogbook 0x000bbacd -[GetOperationPartsDictionary init] (GetOperationPartsDictionary.m:22)
3 UIKit 0x32557f93 -[UIAlertView(Private) _popoutAnimationDidStop:finished:] + 855
4 UIKit 0x3240dc53 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 471
5 UIKit 0x3241357d -[UIViewAnimationState animationDidStop:finished:] + 53
6 QuartzCore 0x36eeac2f CA::Layer::run_animation_callbacks(void*) + 203
7 libdispatch.dylib 0x3140ae91 _dispatch_main_queue_callback_4CF$VARIANT$up + 197
8 CoreFoundation 0x353ad2ad __CFRunLoopRun + 1269
9 CoreFoundation 0x353304a5 CFRunLoopRunSpecific + 301
10 CoreFoundation 0x3533036d CFRunLoopRunInMode + 105
11 GraphicsServices 0x3662c439 GSEventRunModal + 137
12 UIKit 0x32426e7d UIApplicationMain + 1081
13 eLogbook 0x0007767f main (main.m:14)
The thing that is really confusing me about this is that the -[UIAlertView(Private) _popoutAnimationDidStop:finished:] method appears to be calling the init method on my GetOperationPartsDictionary class. From the limited amount of information I've had from users this crash is happening on startup, at which point that class would not have been loaded.
I'm using QuincyKit to deliver the crash reports to a server, from there they're symbolicated using the standard symbolicatecrash script. The version of Xcode being used to symbolicate the crash is the same version that was used to build the binary, and I'm confident that the dSYM used to symbolicate the crash is the correct one - the line numbers for my code are correct for example.
Anyone have any thoughts on this?
Edit: should have added that this is occurring in the field with a live app, but only occasionally. It has affected maybe 1 or 2 users in a thousand or so, but I have never been able to reproduce it either on a device or in the simulator.
Looks like you have called the UIAlertViewDelegate after the alertview has been released.
Release it only in the dealloc method like this :
-(void)dealloc {
self.alertView.delegate = nil; //setting delegate to nil
self.alertView = nil; //if you have defined alert as property
//other release statements of your controller
[super dealloc];
}

iPad App crashes only when it is launched manually (from springboard). Memory issue suspected

I have been trying to solve this problem for 2 days now and it is driving me crazy. When Xcode launches the app it works fine, but If I manually launch the app from Springboard it crashes. The console prints out this:
Jan 20 15:26:29 unknown UIKitApplication:com.yourcompany.ThinClient[0x28cf][1119] <Notice>: ThinClient(1119,0x3db0000) malloc: *** error for object 0x643434: incorrect checksum for freed object - object was probably modified after being freed.
Jan 20 15:26:29 unknown UIKitApplication:com.yourcompany.ThinClient[0x28cf][1119] <Notice>: *** set a breakpoint in malloc_error_break to debug
Jan 20 15:26:29 unknown ThinClient[1119] <Error>: ThinClient(1119,0x3db0000) malloc: *** error for object 0x643434: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
The stack for the crashed thread (usually) looks like this, although sometimes it crashes in different spots:
Thread 5 Crashed:
0 libsystem_kernel.dylib 0x33d4da1c __pthread_kill + 8
1 libsystem_c.dylib 0x353523b4 pthread_kill + 52
2 libsystem_c.dylib 0x3534abf8 abort + 72
3 libsystem_c.dylib 0x3535e822 szone_error + 210
4 libsystem_c.dylib 0x3535e920 free_list_checksum_botch + 16
5 libsystem_c.dylib 0x35361722 tiny_malloc_from_free_list + 82
6 libsystem_c.dylib 0x35361e76 szone_malloc_should_clear + 166
7 libsystem_c.dylib 0x35362fd4 szone_malloc + 4
8 libsystem_c.dylib 0x35386230 malloc_zone_malloc + 48
9 libsystem_c.dylib 0x35386c2c malloc + 28
10 ThinClient 0x0000590c -[MySocket readBytes:] (MySocket.m:231)
11 ThinClient 0x00007b7e -[ThinServerTalker onSocket:readCallbackBytesWaiting:] (ThinServerTalker.m:362)
12 ThinClient 0x000057e2 ReadDataCB (MySocket.m:201)
13 CoreFoundation 0x33cca48a __CFSocketDoCallback + 334
14 CoreFoundation 0x33ccb4a2 __CFSocketPerformV0 + 78
15 CoreFoundation 0x33cc5a72 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
16 CoreFoundation 0x33cc7758 __CFRunLoopDoSources0 + 376
17 CoreFoundation 0x33cc84e4 __CFRunLoopRun + 224
18 CoreFoundation 0x33c58ebc CFRunLoopRunSpecific + 224
19 CoreFoundation 0x33c9b6d2 CFRunLoopRun + 42
20 ThinClient 0x00005656 -[MySocket _connect] (MySocket.m:160)
21 Foundation 0x33d71382 -[NSThread main] + 38
22 Foundation 0x33de35c6 __NSThread__main__ + 966
23 libsystem_c.dylib 0x3535230a _pthread_start + 242
24 libsystem_c.dylib 0x35353bb4 thread_start + 0
I suspect its from the application writing to memory that has already been freed, so I have already tried a few things:
I tried debugging the app with guard malloc, scribble, guard edges, zombie objects, malloc stack, etc..
I tried going to the code where the app crashed and finding an issue there ( i do not believe there is an issue there because the app crashes at different places, but they are all near each other)
I tried going through and commenting out all of my free() function calls.
I still have not found the problem! If anybody could please shed some light on this it would be much appreciated! Thanks! Any Suggestions?
Edit: The app will crash every time if it is launched from springboard, but if Xcode launches it, it will work fine.
I found the issue. I was returning a direct pointer to the bytes in a NSData object from a function. I simply replaced a function called "-(char*)getBytes" with a function called "-(NSData*)getDataCopy". Get data copy instead returns an autoreleased copy of the data class.
To reiterate:
I had this:
-(char*)getBytes{
return _data.bytes;}
and I replaced it with this
-(NSData*)getDataCopy{
return [NSData dataWithData:_data];
}
The issue was I was writing to memory that had already been released.

App rejected: strange iPhone crash log

Apple rejected my app two times due to a crash at launch. I have tested it many times on different devices (iPhone 4, iPhone3GS, Simulator, iPad2) and it never crashed.
EDIT: This is a part of the symbolicated crash log.
Thanks!
Incident Identifier: DD9A5C38-DFE5-4CB5-A15B-8C55967FFFD1
CrashReporter Key: bf318d2d968114ff69d458c2f8cbdc6b869e1ec7
Hardware Model: iPhone3,1
Process: iMetroRoma [2788]
Path: /var/mobile/Applications/8EC59E9D-D070-4CAD-892E-91BCE94AA58C/iMetroRoma.app/iMetroRoma
Identifier: iMetroRoma
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2011-10-24 13:23:22.895 -0700
OS Version: iPhone OS 5.0 (9A334)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x30d828bf __exceptionPreprocess + 163
1 libobjc.A.dylib 0x37f271e5 objc_exception_throw + 33
2 CoreFoundation 0x30ccbb6b -[__NSArrayM objectAtIndex:] + 271
3 iMetroRoma 0x0000426f 0x1000 + 12911
4 CoreLocation 0x34fbc5df -[CLLocationManager onClientEventLocation:] + 1171
5 CoreLocation 0x34fbbf81 -[CLLocationManager onClientEvent:supportInfo:] + 201
6 CoreLocation 0x34fb662f __CLClientInvokeCallback_block_invoke_0 + 55
7 CoreFoundation 0x30d56b31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 13
8 CoreFoundation 0x30d5615f __CFRunLoopDoBlocks + 159
9 CoreFoundation 0x30d55381 __CFRunLoopRun + 1433
10 CoreFoundation 0x30cd84dd CFRunLoopRunSpecific + 301
11 CoreFoundation 0x30cd83a5 CFRunLoopRunInMode + 105
12 GraphicsServices 0x33906fed GSEventRunModal + 157
13 UIKit 0x32d4a743 UIApplicationMain + 1091
14 iMetroRoma 0x000024e3 0x1000 + 5347
15 iMetroRoma 0x0000249c 0x1000 + 5276
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3206732c __pthread_kill + 8
1 libsystem_c.dylib 0x3655df54 pthread_kill + 48
2 libsystem_c.dylib 0x36556fe4 abort + 88
3 libc++abi.dylib 0x31a1ff64 abort_message + 40
4 libc++abi.dylib 0x31a1d346 _ZL17default_terminatev + 18
5 libobjc.A.dylib 0x37f272dc _objc_terminate + 140
6 libc++abi.dylib 0x31a1d3be _ZL19safe_handler_callerPFvvE + 70
7 libc++abi.dylib 0x31a1d44a std::terminate() + 14
8 libc++abi.dylib 0x31a1e81e __cxa_rethrow + 82
9 libobjc.A.dylib 0x37f2722e objc_exception_rethrow + 6
10 CoreFoundation 0x30cd853e CFRunLoopRunSpecific + 398
11 CoreFoundation 0x30cd839e CFRunLoopRunInMode + 98
12 GraphicsServices 0x33906fe6 GSEventRunModal + 150
13 UIKit 0x32d4a73c UIApplicationMain + 1084
14 iMetroRoma 0x000024dc 0x1000 + 5340
15 iMetroRoma 0x00002494 0x1000 + 5268
...
Thread 0 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x00000000 r2: 0x00000001 r3: 0x00000000
r4: 0x00000006 r5: 0x3f54dce8 r6: 0x00000002 r7: 0x2fdffa6c
r8: 0x001a1c20 r9: 0x31a20a4a r10: 0x0000d224 r11: 0x0000cbfc
ip: 0x00000148 sp: 0x2fdffa60 lr: 0x3655df5b pc: 0x3206732c
cpsr: 0x00000010
...
Okay, did you "build and archive" when submitting to appstore?
If you did not, tough luck. There is not much you can do now. Even if you did Build and Archive, and lost the archive, you are out of luck.
If you did however, store the archive file of distribution build, very good!
Have you tried opening this in XCode Organizer (drag and drop the file onto organizer, it should try to symbolicate the crashlog). If not, do it.
When you do it, there are two possibilities:
Either the iMetroRoma functions will get symbolicated (meaning you'll see which line is crashing it) or it wont.
X*: If it does, you know where the application is crashing. Posting the details of that would help us solve the issue for you.
If it does not, then automatic symbolication in XCode is not working. Follow these steps (assuming you did all this from XCode 4):
From /Users/your_username/Library/Developer/Xcode/DerivedData remove
all folders.
From /Users/your_username/Library/Application
Support/iPhone Simulator remove all folders.
Clean your trash.
And then try deleting that crash log from XCode Organizer and drag/drop it again there. Possibly, it might symbolicate it now. If it does do step X*, If it does not, read on.
Now, you will need to do follow the steps on this blog. (Very useful and well documented article).
Hopefully, it will symbolicate now and then move to step X*. If it does not, I'm sorry for not being able to help :)
According to the crash log, it looks like an array out of bounds exception. This means that you accessed an array with an index that doesn't exist. Unfortunately, the most important line (3 iMetroRoma 0x0000426f 0x1000 + 12911
) is not symbolicated which means you have to go hunting for all your calls to objectAtIndex: and think about whether there's a possibility that an invalid index could be used.