• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EXC_BAD_ACCESS when trying to use [NSMutableURLRequest setHTTPBodyStream]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EXC_BAD_ACCESS when trying to use [NSMutableURLRequest setHTTPBodyStream]


  • Subject: Re: EXC_BAD_ACCESS when trying to use [NSMutableURLRequest setHTTPBodyStream]
  • From: Dave Carrigan <email@hidden>
  • Date: Thu, 10 Jan 2008 08:40:46 -0800


On Jan 10, 2008, at 6:57 AM, Bill Garrison wrote:

I think you'll need to retain your NSURLConnection instance. It's probably being released out from under you by the framework (e.g. an internal autorelease pool is popped, leaving the instance released but nil'd out. When messages are sent to released (and now invalid) Cocoa object instances, you'll get an EXC_BAD_ACCESS exception.

Try [[NSURLConnection connectionWithRequest:request delegate:self] retain] and see what that does.


I've had this suggestion from a few people, so I'm going to report back to the list that the unretained objects is not the cause of my problem. I changed my code to look like:

NSMutableURLRequest* request = [[NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0] retain];
NSInputStream* stream = [[NSInputStream inputStreamWithFileAtPath:filename] retain];
[request setHTTPBodyStream:stream];
[request setHTTPMethod:@"PUT"];
[[NSURLConnection connectionWithRequest:request delegate:self] retain];


  ...

NSURL* url = [[NSURL URLWithString:@"http://localhost:23456/ reflect"] retain];

So every autorelease object I'm creating now has an explicit retain, but the code still crashes.

On a different note, is there source code around somewhere that I can add to gdb's search path so that I'm not stuck with reading assembly in gdb?

--
Dave Carrigan
email@hidden
Seattle, WA, USA

Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________

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

  • Follow-Ups:
    • Re: EXC_BAD_ACCESS when trying to use [NSMutableURLRequest setHTTPBodyStream]
      • From: "I. Savant" <email@hidden>
References: 
 >EXC_BAD_ACCESS when trying to use [NSMutableURLRequest setHTTPBodyStream] (From: Dave Carrigan <email@hidden>)

  • Prev by Date: Re: Using NSValueTransformer for encryption
  • Next by Date: Re: Garbage Collection Problem
  • Previous by thread: EXC_BAD_ACCESS when trying to use [NSMutableURLRequest setHTTPBodyStream]
  • Next by thread: Re: EXC_BAD_ACCESS when trying to use [NSMutableURLRequest setHTTPBodyStream]
  • Index(es):
    • Date
    • Thread