views:

62

answers:

2

Hi all,

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...

+1  A: 

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 Gottlieb
@Ben, You know, this really should be a comment.
Jacob Relkin
Thanks guys, the thing is this crash occurs on people's devices rather than in the simulator...
nicktmro
Zombie detection may still help. As Ben said, it looks like your delegate for the NSURLConnection is no longer valid.
Robot K
Cool. I have done that, hopefully it will crash again...
nicktmro
A: 

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.

Andrew
The crash was because the object was released and then the memory was reclaimed. In my code I was trying to call delegate respondsToSelector: but now delegate was actually some primitive type that does not adopt the NSObject protocol thus was unable to handle the message.
nicktmro