EXC_BAD_ACCESS on iPhone #2

Closed
miclee opened this Issue Dec 6, 2010 · 7 comments

4 participants

@miclee

Hi,

Found a problem when using AFURLCache on iPhone (simulator or device, IOS 4.1).

Steps to repeat:

  1. Specify the NSURLCache

    AFURLCache* cache = [[[AFURLCache alloc] initWithMemoryCapacity:0  diskCapacity:0 diskPath:@""] autorelease];
    [NSURLCache setSharedURLCache:cache];
    
  2. Navigate UIWebView to http://www.google.com/

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/"]];
    [webView loadRequest:request];
    
  3. Click the Image link at the top-left will result in EXC_BAD_ACCESS. (Sometimes you need to click 'Image' and 'Web' back and forth until AFURLCache tries to actually load a page from the cache.)

The AFURLCache works fine on many sites. One thing that looks suspicious on Google.com is that there is a file with content type: text/cache-manifest.

Mic

@artifacts
Owner

I think your problem might orginate in data URLs that google uses for some images.
http://en.wikipedia.org/wiki/Data_URI_scheme

I'm investigating a similiar issue where an EXC_BAD_ACCESS occures in copyConstantHeaderFieldValue somewhere deep in the NSURL loading framework. Not sure yet if it's the same problem. Debugging is quite hard since no language exception is thrown, but a machine exception.

Some readings:

https://devforums.apple.com/message/328401
http://stackoverflow.com/questions/916718/nsurlconnection-crashing-under-10-5-7
https://devforums.apple.com/message/325237

@artifacts
Owner

After a longer debugging session I am convinced, that this is an iOS Bug introduced in iOS4. The scenario:

  • A HTML page is loaded via loadRequest: in an UIWebView (using AFURLCache).
  • After loading finished, some JavaScript is evaluated in UIWebView to do an ajax call for exchanging the html body.

At this point, somewhere in the deeps of Apple's CoreFoundation url connection and loading frameworks a machine exception occures when some routine is tryging to access the HTTP header fields. Since no obj-c Exception is thrown and I have no zombie or other useful debugging information, I'm not able to fix anything there.
The Problem only occures when UIWebView tries to load resources via ajax.

Next steps:

  • File a Bug
  • Test with 4.3 beta 2
@artifacts
Owner

addendum: Why iOS4 ?
I have a report from a developer who hat a similar issue in iOS4. Compiling against iOS3 SDK solved the problem. I did not try to reproduce that yet.

@chlorell

i have a similar problem. not exactly with uiwebview, but i get a segfault in the same place. however there is something which may help: when i use AFCache - when NSURLConnection calls - (void)connection:(NSURLConnection *)theConnection didReceiveResponse:(NSURLResponse *)response - the response isn't a NSHTTPURLResponse object.
If i change it in AFURLCache.m to store NSHTTPURLResponse, somehow i still get NSURLResponse object.

@orff

Did anyone make headway on this bug. I am looking to integrate AFCache into my project, but this bug is a pretty severe limitation for me. I have user inputted web URLS. google.com is bound to come up ;-)

Chlorell, did your patch at least stop the bad access crashing ? The page loads up in a WebView. The crash happens after a render, so I would be happy for now with just a way to stop the exception.

@chlorell

nope, i justed narrowed the group of sites which are managed by AFCache ;)

@artifacts
Owner

see #9

@artifacts artifacts closed this Sep 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment