views:

328

answers:

1

Hi Iam fighting with this for the past 48 hours searching all forums with no use. Iam using NSURLConnection asynchronous to download a series of web files, it randomly crashes ( after downloading a few files which is not fixed). Please see the call stack below:

0 0x35b634f4 in objc_msgSend

1 0x3527c2ca in CFEqual

2 0x3532e750 in __CFBasicHashStandardEquateKeys

3 0x35330514 in ___CFBasicHashFindBucket_Linear

4 0x3527c07c in CFBasicHashFindBucket

5 0x3527bf5c in CFDictionaryGetValue

6 0x31d15cb4 in HTTPMessage::copyConstantHeaderFieldValue

7 0x31d6526c in URLRequest::copyConstantHeaderFieldValue

8 0x31d606f8 in HTTPProtocol::getCacheStoragePolicy

9 0x31d62cd0 in HTTPProtocol::updateForHeader

10 0x31d64524 in HTTPProtocol::performHeaderRead

11 0x31d64bf8 in HTTPProtocol::httpReadStreamEvent

12 0x352c4302 in _signalEventSync

13 0x352c427c in _cfstream_shared_signalEventSync

14 0x352ed294 in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION

15 0x352ef0e2 in __CFRunLoopDoSources0

16 0x352f0058 in __CFRunLoopRun

17 0x352970c2 in CFRunLoopRunSpecific

18 0x35296fd0 in CFRunLoopRunInMode

19 0x30a1f31c in +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:]

20 0x309ef618 in -[NSThread main]

21 0x30a75146 in NSThread__main

After seeing a previous thread on this on stackoverflow it is indeed a problem with redirect requests being sent. The solution suggested there was to implement - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *) redirectResponse { return request; } I did that but still the crash is there . Also the behaviour before crash is that , willSendRequest is being called twice and no other delegate method is called for this request. It crashes internally in NSURLResponse.

would really appreciate any pointers Thanks bvk4you

A: 

This may helpful: http://stackoverflow.com/questions/2802180/asynchronous-nsurlconnection-throws-exc-bad-access

For example:

I've fixed my problem with NSZombieEnabled flag. My problem was supplied NSURL was autorelease object. So the URL object deallocated at some specific time, and accessing to it failed in internal API code.

Eonil