NSURLRequest and WebKit/NSURLConnection crash

  • 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
  • NSZombie to see what it tries to send a message to?
    Without the encoded data to send but e.g.  "HIHO" it also crashes?

    Am 04.09.2007 um 21:59 schrieb Mark Christian:

    > 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
  • Hi, folks;
    I've found the solution, and I thought I'd post it here in case it
    ever happens to anyone else.

    The function at the end, [self loadURLRequest], loads urlRequest in
    the main frame of a WebView. It works as expected if the page has no
    frames, but if it does have a frame, you need to retain the frame you
    load the URL request in. Even though I was using [webView mainFrame],
    it's de-allocating when frames exist.

    Thanks for everyone's suggestions.

    Mark

    On 4-Sep-07, at 4:59 PM, Mark Christian wrote:

    > 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
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