NSURLConnection crashes with EXC_BAD_ADDRESS -- can't find why...
NSURLConnection crashes with EXC_BAD_ADDRESS -- can't find why...
- Subject: NSURLConnection crashes with EXC_BAD_ADDRESS -- can't find why...
- From: David Paeme <email@hidden>
- Date: Wed, 8 Apr 2009 14:55:00 +0200
Hi all,
I'm writing an application that accesses a http server via
NSURLConnection's sendSynchronousRequest method, and it keeps crashing
on me with an EXC_BAD_ADDRESS signal, without ever reaching the server.
Here's sample code (very similar to what's in aaron hillegass' book):
...
NSString *urlString = [NSString stringWithFormat:@"%@?act=upd&lu=
%@",WS_URL,[[NSUserDefaults standardUserDefaults]
objectForKey:@"lastDbUpdate"]];
NSLog (@"urlString: %@",urlString);
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:15];
NSURLResponse *urlResponse;
NSError *error;
NSData *urlData = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&urlResponse error:&error];
...
The code is in an object's method which gets called from the
appcontroller, the data is xml and gets parsed a bit further. There's
no threading code (ripped it out, just to be sure that the problem
wasn't there)
This is the stack trace:
#0 0x94e7f1c6 in mach_msg_trap ()
#1 0x94e869bc in mach_msg ()
#2 0x90cfe0ae in CFRunLoopRunSpecific ()
#3 0x90cfecd8 in CFRunLoopRunInMode ()
#4 0x90ad5b1b in CFURLConnectionSendSynchronousRequest ()
#5 0x9575526b in +[NSURLConnection
sendSynchronousRequest:returningResponse:error:] ()
#6 0x00002c26 in -[EPBackEnd updateArticles] (self=0x12dc20,
_cmd=0x77b76) at /Users/david/Code/Mac/EP/v0.2/EPBackEnd.m:287
#7 0x0000219d in -[AppController refreshArticles:] (self=0x12dbb0,
_cmd=0x77223, sender=0x123110) at /Users/david/Code/Mac/EP/v0.2/
AppController.m:52
#8 0x96b9753b in -[NSApplication sendAction:to:from:] ()
#9 0x96b97478 in -[NSControl sendAction:to:] ()
#10 0x96b972fe in -[NSCell _sendActionFrom:] ()
#11 0x96b96957 in -[NSCell trackMouse:inRect:ofView:untilMouseUp:] ()
#12 0x96b961aa in -[NSButtonCell
trackMouse:inRect:ofView:untilMouseUp:] ()
#13 0x96b95a64 in -[NSControl mouseDown:] ()
#14 0x96b941a3 in -[NSWindow sendEvent:] ()
#15 0x96b60d49 in -[NSApplication sendEvent:] ()
#16 0x96abe69f in -[NSApplication run] ()
#17 0x96a8b8a4 in NSApplicationMain ()
#18 0x0000201c in main (argc=1, argv=0xbffff778) at /Users/david/Code/
Mac/EP/v0.2/main.m:13
And now for the very weird part: sometimes it doesn't crash, and works
as it should. A consequent launch makes the app crash. - here i could
be guessing something with the cache, but that should be disabled by
[[NSURLCache sharedURLCache] setMemoryCapacity:0] and [NSURLCache
sharedURLCache] setDiskCapacity:0]
Does anyone have an idea what makes the crash happen?
Thanks!!
D.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden