NSURLConnection crash on POST

  • Hi, folks;
    I've got a weird crash that's driving me crazy. Hopefully someone out
    there can shed some light on the situation.

    I have a method that navigates a WebView to a particular URL.
    Sometimes, it posts data along with the request, sometimes not. The
    POST data is sorted in an NSData called pendingData, and the function
    looks something like this:

    if (pendingData == nil) {
      // Simple request
      urlRequest = [NSURLRequest requestWithURL:url];
    } else {
      // POST request
      urlRequest = [NSMutableURLRequest requestWithURL:url];
      [urlRequest setHTTPMethod:@"POST"];

      // Encode data
      // (snipped)
    }

    [self loadURLRequest:urlRequest];

    In the case where pendingData is nil, everything works perfectly. In
    the case where it's not nil, I get an NSURLConnection. My POST data
    encoding definitely works, because it has worked in the past --
    something else got broken. Just setting the HTTP method to "POST" is
    enough to cause the crash.

    Here's the crash log:
    #0  0x90a594c7 in objc_msgSend ()
    #1  0xbfffe9e8 in ?? ()
    #2  0x92859ee4 in -[NSURLConnection(NSURLConnectionInternal)
    _sendCallbacks] ()
    #3  0x92859ab5 in _sendCallbacks ()
    #4  0x9082cf92 in CFRunLoopRunSpecific ()
    #5  0x9082cace in CFRunLoopRunInMode ()
    #6  0x92ded8d8 in RunCurrentEventLoopInMode ()
    #7  0x92decfe2 in ReceiveNextEventCommon ()
    #8  0x92dece39 in BlockUntilNextEventMatchingListInMode ()
    #9  0x93293465 in _DPSNextEvent ()
    #10 0x93293056 in -[NSApplication
    nextEventMatchingMask:untilDate:inMode:dequeue:] ()
    #11 0x9328cddb in -[NSApplication run] ()
    #12 0x93280d2f in NSApplicationMain ()
    #13 0x0000231e in main (argc=1, argv=0xbffff88c) at /Users/mark/Work/
    Provisioning/Macintosh/trunk/Provisioning Wizard/main.m:31

    If anyone out there can help, I'd be really appreciative. Thank you
    in advance;
    Mark
  • When you "get" your NSURLConnection (you don't show this), do you set
    the delegate? Do you take care that the delegate does not get released/
    autoreleased while the connection is still pending?

    The -[NSURLConnection(NSURLConnectionInternal) _sendCallbacks] method,
    followed immediately by a crasher in objc_msgSend (which is a strong
    indicator of a message sent to a released object) is very suggestive.

    — F

    On Sep 4, 2007, at 1:48 PM, Mark Christian wrote:

    > In the case where it's not nil, I get an NSURLConnection.
    ...
    > Here's the crash log:
    > #0  0x90a594c7 in objc_msgSend ()
    > #1  0xbfffe9e8 in ?? ()
    > #2  0x92859ee4 in -[NSURLConnection(NSURLConnectionInternal)
    > _sendCallbacks] ()
  • The NSURLConnection is implicit -- I send my NSURLRequest to a
    WebFrame, and some time later, the NSURLConnection error pops up. I
    never set the delegate myself.

    Right now, the NSURLRequest is an autoreleased object. However, if I
    change it to an alloc/init retained object, I still get the crash.

    Also, and frustratingly, this exact code used to work. The only
    difference is that the WebFrame is now pointing to a page with a
    frameset, whereas it wasn't before.

    Where else can I look for release bugs?

    Mark

    On 4-Sep-07, at 5:26 PM, Fritz Anderson wrote:

    > When you "get" your NSURLConnection (you don't show this), do you
    > set the delegate? Do you take care that the delegate does not get
    > released/autoreleased while the connection is still pending?
    >
    > The -[NSURLConnection(NSURLConnectionInternal) _sendCallbacks]
    > method, followed immediately by a crasher in objc_msgSend (which is
    > a strong indicator of a message sent to a released object) is very
    > suggestive.
    >
    > — F
    >
    >
    > On Sep 4, 2007, at 1:48 PM, Mark Christian wrote:
    >
    >> In the case where it's not nil, I get an NSURLConnection.
    > ...
    >> Here's the crash log:
    >> #0  0x90a594c7 in objc_msgSend ()
    >> #1  0xbfffe9e8 in ?? ()
    >> #2  0x92859ee4 in -[NSURLConnection(NSURLConnectionInternal)
    >> _sendCallbacks] ()
    >
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today