4

I have been fighting with this for the past 48 hours and searching all forums with no use. I am using NSURLConnection to asynchronously download a series of web files. It randomly crashes after downloading a few files, the number of 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.

Jeremy W. Sherman
  • 35,901
  • 5
  • 77
  • 111
Vamshi
  • 115
  • 1
  • 8
  • Still hitting the issue help anyone? – Vamshi Jun 25 '10 at 07:24
  • Hi Does no one has clue about this or just don't want to answer new users? – Vamshi Jun 26 '10 at 06:58
  • Forgot to add that , this issue is happening on iPhone with iOS 4.0 Does not happen on 3.0 – Vamshi Jun 28 '10 at 08:57
  • I'm experiencing similar but in different situation. My EXC_BAD_ACCESS happen after few seconds connection:didFailWithError: randomly. I coudln't figure out any solution. – eonil Jul 18 '10 at 09:04

1 Answers1

0

This may helpful: 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.

Community
  • 1
  • 1
eonil
  • 83,476
  • 81
  • 317
  • 516