App Crashing in NSURLConnection - iphone

I am trying to figure out what is causing this crash. I have built and given the app to our testers but we cannot seem to reproduce this reliably. It just happens sometimes...
Thread 0 Crashed:
0 libobjc.A.dylib 0x000027da objc_msgSend + 18
1 Foundation 0x00032896 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 62
2 Foundation 0x00032818 _NSURLConnectionDidFinishLoading + 72
3 CFNetwork 0x00010dd8 URLConnectionClient::_clientDidFinishLoading(URLConnectionClient::ClientConnectionEventQueue*) + 160
4 CFNetwork 0x00004ad4 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 96
5 CFNetwork 0x000049c4 URLConnectionClient::processEvents() + 64
6 CFNetwork 0x00004976 URLConnection::multiplexerClientPerform(RunLoopMultiplexer*) + 30
7 CFNetwork 0x000048f4 MultiplexerSource::perform() + 120
8 CFNetwork 0x00004872 MultiplexerSource::_perform(void*) + 2
9 CoreFoundation 0x00055f1e __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
10 CoreFoundation 0x00027ba0 __CFRunLoopDoSources0 + 376
11 CoreFoundation 0x00027444 __CFRunLoopRun + 224
12 CoreFoundation 0x00027270 CFRunLoopRunSpecific + 224
13 CoreFoundation 0x00027178 CFRunLoopRunInMode + 52
14 GraphicsServices 0x000045ec GSEventRunModal + 108
15 GraphicsServices 0x00004698 GSEventRun + 56
16 UIKit 0x0000411c -[UIApplication _run] + 396
17 UIKit 0x00002128 UIApplicationMain + 664
18 myapp 0x000020d8 main (main.m:14)
19 myapp 0x0000208c start + 32
Any advice would be greatly appreciated. The app is built in XCode 3.2.4 using SDK 4.1.
Cheers...

I would try turning on NSZombieEnabled and see if that sheds any light on the issue. Is the delegate for the connection still around and valid?

Ben has some sound advice. Turn NSZombieEnabled to on.
I can tell you with almost 100% certainty that it is crashing because you have a nil object when the delegate is attempting to send it a message.
The fact that it is only crashing sometimes, tells me that you are probably using autorelease. Autorelease never decrements the retain count at exactly the same time, so sometimes your object will still be alive when it gets a delegate message and the app works. However, sometimes that object will have been released and the app crashes.

Related

iPhone app crash with unknown error

I am developing an application to take photos and upload the photos to remote server.
I have customized camera view using overlay view. App allows to take more than 1 photos per time and photos will be saved to device just after taking photos. When I am taking photos app gives memory warning and then crash. Followings are the from crash report. I have talked with Apple support team and they said this is not due to memory issue. This is because of trying to send an action to one of your controller object that no longer exists.
OS Version: iPhone OS 4.3.3 (8J2)
Report Version: 104
Exception Type: EXC_BAD_ACCESS
(SIGSEGV) Exception Codes:
KERN_INVALID_ADDRESS at 0x73980000
Crashed Thread: 0
Thread 0 name: Dispatch queue:
com.apple.main-thread Thread 0
Crashed: 0 libobjc.A.dylib
0x34499c9a objc_msgSend + 18 1
UIKit
0x30a8bc1a
-[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 86 2 CoreFoundation
0x308f056a -[NSObject(NSObject)
performSelector:withObject:withObject:]
+ 18 3 UIKit 0x309feec2 -[UIApplication
sendAction:to:from:forEvent:] + 78 4
UIKit
0x309fee62 -[UIApplication
sendAction:toTarget:fromSender:forEvent:]
+ 26 5 UIKit 0x309fee34 -[UIControl
sendAction:to:forEvent:] + 32 6
UIKit
0x309feb86 -[UIControl(Internal)
_sendActionsForEvents:withEvent:] + 350 7 UIKit
0x309ff41c -[UIControl
touchesEnded:withEvent:] + 336 8
UIKit
0x309e452e
_UIGestureRecognizerSortAndSendDelayedTouches
+ 2194 9 UIKit 0x309e3bfa
_UIGestureRecognizerUpdateObserver + 690 10 CoreFoundation
0x30957a2e
CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
+ 10 11 CoreFoundation 0x3095945e __CFRunLoopDoObservers +
406 12 CoreFoundation
0x3095a754 __CFRunLoopRun + 848 13
CoreFoundation
0x308eaebc CFRunLoopRunSpecific + 224
14 CoreFoundation
0x308eadc4 CFRunLoopRunInMode + 52 15
GraphicsServices
0x30269418 GSEventRunModal + 108 16
GraphicsServices
0x302694c4 GSEventRun + 56 17 UIKit
0x30a10d62 -[UIApplication _run] +
398 18 UIKit
0x30a0e800 UIApplicationMain + 664 19
hand-e-pix
0x000025a4 main (main.m:14) 20
hand-e-pix
0x0000254c start + 32
Can anyone please help me to identify what cause this problem?
Many Thanks
Regards
Chin
This could easily be related to a retain/release issue. Make sure you balance your reetain/release calls. Also make sure you do not reference any deallocated objects in your code.
You might want to take a look at enabling NSZombieEnabled in order to track this one down.
You can find information about how to enable it here.

Crash on [NSURLConnection releaseDelegate] in a function without NSURLConnections, how do I culprit?

Hullo,
I am experimenting a very vicious crash that shows up in the following way in the device logs:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x50000008
Crashed Thread: 0`
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x33b24c98 objc_msgSend + 16
1 Foundation 0x3429465a _NSURLConnectionReleaseClient + 30
2 CFNetwork 0x355ac608 ClientContextHolder<CFURLConnectionClient_V4>::forget() + 20
3 CFNetwork 0x355ac5ea URLConnectionClient::releaseClientLocked() + 34
4 CFNetwork 0x355a0e9a URLConnectionClient::processEvents() + 170
5 CFNetwork 0x355a0de2 URLConnection::multiplexerClientPerform(RunLoopMultiplexer*) + 30
6 CFNetwork 0x355a0d54 MultiplexerSource::perform() + 120
7 CFNetwork 0x355a0cd2 MultiplexerSource::_perform(void*) + 2
8 CoreFoundation 0x3039ca72 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
9 CoreFoundation 0x3039e758 __CFRunLoopDoSources0 + 376
10 CoreFoundation 0x3039f4e4 __CFRunLoopRun + 224
11 CoreFoundation 0x3032febc CFRunLoopRunSpecific + 224
12 CoreFoundation 0x3032fdc4 CFRunLoopRunInMode + 52
13 GraphicsServices 0x35571418 GSEventRunModal + 108
14 GraphicsServices 0x355714c4 GSEventRun + 56
15 UIKit 0x358c7d62 -[UIApplication _run] + 398
16 UIKit 0x358c5800 UIApplicationMain + 664
17 inArrivo 0x000023ca main (main.m:14)
18 inArrivo 0x00002394 start + 32
After having enabled NSZombie I also have a crash on the compiler log of the following form:
2011-05-09 16:12:24.400 inArrivo[5019:707] * -[NSURLConnection releaseDelegate]: message sent to deallocated instance 0x5d61670
appearing on the app main with the last NSLog comeing from a function with no url connections. Also if I remove some pieces of very innocent code from that function, no crash occurs, and the same happens when I run the complete application on the simulator.
Could someone give me some hints about what I may do to locate the piece of code producing the crash? Normal debugging of course is of little help here.
Thanks,
Fabrizio Bartolomucci
The message indicates that the delegate for NSURLConnection was deallocated. I would suggest you check the delegate object to see if you are doing an extra release on it.

App crashes but only when it's build for Ad-Hoc distro

My problem is this. I have an app that builds and runs fine in Debug mode, no crashes, memory errors, etc. As soon as I do an Ad-hoc build and try to run it on the device the main thread crashes at a certain point, for no apparent reason... The stack trace I managed to get from the device log is thus...
0 libSystem.B.dylib 0x30d7c2d4 __kill + 8
1 libSystem.B.dylib 0x30d7c2c4 kill + 4
2 libSystem.B.dylib 0x30d7c2b6 raise + 10
3 libSystem.B.dylib 0x30d90d72 abort + 50
4 libstdc++.6.dylib 0x34981a20 __gnu_cxx::__verbose_terminate_handler() + 376
5 libobjc.A.dylib 0x34a83594 _objc_terminate + 104
6 libstdc++.6.dylib 0x3497fdf2 __cxxabiv1::__terminate(void (*)()) + 46
7 libstdc++.6.dylib 0x3497fe46 std::terminate() + 10
8 libstdc++.6.dylib 0x3497ff16 __cxa_throw + 78
9 libobjc.A.dylib 0x34a824c4 objc_exception_throw + 64
10 CoreFoundation 0x3587a7c2 +[NSException raise:format:arguments:] + 62
11 CoreFoundation 0x3587a7fc +[NSException raise:format:] + 28
12 QuartzCore 0x31071222 CALayerSetPosition(CALayer*, CA::Vec2<double> const&, bool) + 134
13 QuartzCore 0x31071190 -[CALayer setPosition:] + 32
14 UIKit 0x341e4378 -[UIView(Geometry) setCenter:] + 16
15 MyApp 0x00012b2c 0x1000 + 72492
16 MyApp 0x0001276a 0x1000 + 71530
17 UIKit 0x341e3270 -[UIViewController view] + 104
18 UIKit 0x341efd04 -[UIViewController contentScrollView] + 16
19 UIKit 0x341efb74 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 24
20 UIKit 0x341efa72 -[UINavigationController _layoutViewController:] + 18
21 UIKit 0x341ef4cc -[UINavigationController _startTransition:fromViewController:toViewController:] + 248
22 UIKit 0x341ef358 -[UINavigationController _startDeferredTransitionIfNeeded] + 176
23 UIKit 0x341e30be -[UINavigationController pushViewController:transition:forceImmediate:] + 634
24 UIKit 0x341e2e34 -[UINavigationController pushViewController:animated:] + 28
25 MyApp 0x00004f80 0x1000 + 16256
26 UIKit 0x3420b834 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 656
27 UIKit 0x342cb60c -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 124
28 Foundation 0x31181df6 __NSFireDelayedPerform + 362
29 CoreFoundation 0x3583109c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
30 CoreFoundation 0x35830b54 __CFRunLoopDoTimer + 844
31 CoreFoundation 0x358021ae __CFRunLoopRun + 1082
32 CoreFoundation 0x35801c80 CFRunLoopRunSpecific + 224
33 CoreFoundation 0x35801b88 CFRunLoopRunInMode + 52
34 GraphicsServices 0x320c84a4 GSEventRunModal + 108
35 GraphicsServices 0x320c8550 GSEventRun + 56
36 UIKit 0x341dc322 -[UIApplication _run] + 406
37 UIKit 0x341d9e8c UIApplicationMain + 664
The other really strange thing is that if you close the app and stop it running (after the crash) in the background and then relaunch it, it bails out almost immediately quoting...
<Warning>: Application 'MyApp' exited abnormally with signal 11: Segmentation fault
Which I'm lead to believe is a memory access error (uninitialised memory access). I'm not doing anything crazy with pointers or anything so all I can presume is that it's a problem with the CF libraries...
Any thoughts or help would be HUGELY appreciated :)
It's hard to say exactly what the answer is without knowing more, but my first guess is that you are providing some invalid value to a UIView's center property.
There are two pieces of information missing that could help you/me find the answer.
First, lines like these in the stack trace need to be symbolicated:
15 MyApp 0x00012b2c 0x1000 + 72492
16 MyApp 0x0001276a 0x1000 + 71530
Knowing what is happening in those two lines will help you track it down, and knowing what the exception that got thrown (starting at line 11 in the stack trace) contains will help further. You may be able to get this information from looking at the device's Console output in Xcode's Organizer.
You can symbolicate the crash report if you have the dSYM file that was created when you built the app for AdHoc distribution. Dragging the crash report into Xcode's Organizer window will attempt to symbolicate it automatically. If that doesn't work, you can try using the symbolicatecrash script directly. It's tucked away in a path like this:
/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash

popViewControllerAnimated:YES crashes my app

My app crashes when I do [self.navigationController popViewControllerAnimated:YES].
It crashes more on Device than on Simulator. Please suggest how to fix this?
Date/Time: 2010-11-09 10:51:41.325 +0800
OS Version: iPhone OS 4.0.1 (8A306)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000286e objc_msgSend + 18
1 CoreFoundation 0x00002c30 -[NSObject(NSObject) release] + 24
2 libobjc.A.dylib 0x00003c1a objc_setProperty + 114
3 UIKit 0x000693d4 -[UINavigationController setDisappearingViewController:] + 24
4 UIKit 0x0007d5c0 -[UINavigationController _clearLastOperation] + 40
5 UIKit 0x0007d4b4 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 556
6 UIKit 0x0007d248 -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 204
7 UIKit 0x0007d0b6 -[UINavigationTransitionView _navigationTransitionDidStop] + 450
8 UIKit 0x00059974 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 184
9 UIKit 0x0005987e -[UIViewAnimationState animationDidStop:finished:] + 34
10 QuartzCore 0x000127ba run_animation_callbacks(double, void*) + 286
11 QuartzCore 0x0001265c CA::timer_callback(__CFRunLoopTimer*, void*) + 116
12 CoreFoundation 0x00071a54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
13 CoreFoundation 0x00073ede __CFRunLoopDoTimer + 854
14 CoreFoundation 0x0007485e __CFRunLoopRun + 1082
15 CoreFoundation 0x0001d8e4 CFRunLoopRunSpecific + 224
16 CoreFoundation 0x0001d7ec CFRunLoopRunInMode + 52
17 GraphicsServices 0x000036e8 GSEventRunModal + 108
18 GraphicsServices 0x00003794 GSEventRun + 56
19 UIKit 0x000062a0 -[UIApplication _run] + 396
20 UIKit 0x00004e10 UIApplicationMain + 664
21 tenpay 0x00006124 main (main.m:13)
22 tenpay 0x00002324 start + 44
myviewcontroller = [[[MyViewController alloc]init]autorelease];
[self.navigationController pushViewController:myviewcontroller animated:YES];
[myviewcontroller release]; //This is my bug !!! I just fixed it.
This usually means you are sending a message to a released object which is a bad idea.
From the stack you can see that it is sending a release message to an object. I'd suggest that the object has already been released and thus hasa retain count of 0. Therefore a further release would be invalid.
I believe if you turn on a flag, I think it's called Zombie detection or something like that, then any message to a released object will generate a more descriptive message.
Perhaps a more experienced developer can jump in here with more details.
Yes, I believe Derek is pointing you in the right direction. Could you possibly list what kind of memory-related operations you are performing on the active controller before sending this release message (the release message is being sent implicitly when you try to pop it out). Please clarify if you are using autorelease for this controller,etc... Also it might be helpful to see what are the associated properties that you may have associated with this controller (ex: #property(nonatomic, retain, etc...)) if there are any.

iPhone: App crash in MapView after 20 min

I am working on an app that tracks a users location. After about 20 minutes it seems that the app always crashes, and I am not sure why. Device logs show:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x069f6000
Crashed Thread: 0
Thread 0 Crashed:
0 Ride 0x00012e00 -[Route addCoordinate:] (Route.m:92)
1 Ride 0x0000877a -[MyRidesMapViewController locationManager:didUpdateToLocation:fromLocation:] (MyRidesMapViewController.m:528)
2 CoreLocation 0x0000931c -[CLLocationManager onClientEventLocation:] + 584
3 CoreLocation 0x00007552 -[CLLocationManager onClientEvent:supportInfo:] + 98
4 CoreLocation 0x000076a0 OnClientEvent + 16
5 CoreLocation 0x00002ade CLClientInvokeCallback(__CLClient*, CLClientEvent, __CFDictionary const*) + 42
6 CoreLocation 0x0000512c CLClientHandleDaemonDataLocation(__CLClient*, CLClientLocation const*, __CFDictionary const*) + 204
7 CoreLocation 0x0000528a CLClientHandleDaemonData(__CFMessagePort*, long, __CFData const*, void*) + 298
8 CoreFoundation 0x0006936a __CFMessagePortPerform + 242
9 CoreFoundation 0x00071aa4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
10 CoreFoundation 0x00073848 __CFRunLoopDoSource1 + 160
11 CoreFoundation 0x00074626 __CFRunLoopRun + 514
12 CoreFoundation 0x0001d8e4 CFRunLoopRunSpecific + 224
13 CoreFoundation 0x0001d7ec CFRunLoopRunInMode + 52
14 GraphicsServices 0x000036e8 GSEventRunModal + 108
15 GraphicsServices 0x00003794 GSEventRun + 56
16 UIKit 0x000062a0 -[UIApplication _run] + 396
17 UIKit 0x00004e10 UIApplicationMain + 664
18 Ride 0x00002a20 main (main.m:14)
19 Ride 0x000029d4 start + 32
Looks like I am trying to release something that has already been released, but what?! I have NSZombie enabled, and it does not seem to help.
It used to work, and I recently updated my class to use self. for anything that I synthesized, could this be the issue?
EDIT: I updated the error. It seems to be listing the line numbers for each line, but they do not seem to be helping to find the issue.
Do you have NSZombie enabled while you're running on the device? If so chances are you are running out of memory. As you know, NSZombie keeps released objects around so you can detect a double release.
Chances are you do have some memory issues though. Does the static analyzer show you anything? (shift-command-A).
Setting the location manager delegate to nil AND THEN releasing it fixed the crash for me.