10

I'm running into some really strange EXC_BAD_ACCESS crashes which are totally reproducible with the last 2 Xcode 7 Beta versions (including the GM from last night):

When running my application, AFNetworking crashes with an EXC_BAD_ACCESS message in AFURLConnectionOperation.m line 154. More precisely, here is the stacktrace:

thread #1: tid = 0x23b173, 0x000000010b89beaf CoreFoundation`___forwarding___ + 767, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
    frame #0: 0x000000010b89beaf CoreFoundation`___forwarding___ + 767
    frame #1: 0x000000010b89bb28 CoreFoundation`__forwarding_prep_0___ + 120
  * frame #2: 0x0000000105a4507e MyApp`-[AFURLConnectionOperation .cxx_destruct](self=0x00007fc4d873aa20, _cmd=(null)) + 494 at AFURLConnectionOperation.m:154
    frame #3: 0x000000010af637bb libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 127
    frame #4: 0x000000010af6e390 libobjc.A.dylib`objc_destructInstance + 93
    frame #5: 0x000000010b94e7c6 CoreFoundation`-[NSObject(NSObject) __dealloc_zombie] + 150
    frame #6: 0x00000001087ee9df Foundation`-[NSOperation dealloc] + 89
    frame #7: 0x0000000105a3dca2 MyApp`-[AFURLConnectionOperation dealloc](self=0x00007fc4d873aa20, _cmd="dealloc") + 162 at AFURLConnectionOperation.m:216
    frame #8: 0x000000010af78afe libobjc.A.dylib`objc_object::sidetable_release(bool) + 232
    frame #9: 0x0000000105a31dd1 MyApp`__destroy_helper_block_((null)=0x00007fc4d8b27000) + 65 at AFHTTPRequestOperation.m:0
    frame #10: 0x000000010d1226b1 libsystem_blocks.dylib`_Block_release + 128
    frame #11: 0x000000010d0a549b libdispatch.dylib`_dispatch_client_callout + 8
    frame #12: 0x000000010d08d34b libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1738
    frame #13: 0x000000010b8a63e9 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    frame #14: 0x000000010b867939 CoreFoundation`__CFRunLoopRun + 2073
    frame #15: 0x000000010b866e98 CoreFoundation`CFRunLoopRunSpecific + 488
    frame #16: 0x000000010dd2cad2 GraphicsServices`GSEventRunModal + 161
    frame #17: 0x00000001095c9676 UIKit`UIApplicationMain + 171
    frame #18: 0x0000000105767d3f MyApp`main(argc=7, argv=0x00007fff5a541620) + 111 at main.m:33
    frame #19: 0x000000010d0da92d libdyld.dylib`start + 1

I set enabled Zombie Objects in my scheme and got the following error

*** -[NSMutableURLRequest release]: message sent to deallocated instance 0x7fc4d8acc460

Would any one of you have an idea what is causing the crash? Using Xcode 6 works like a charm but I'd really like to use the new Swift features in my code ...

4
  • May be AFNetworking developer still working to make their API compatible with Swift 2.0. Question itself a one reason that I minimise use of third party APIs. Commented Sep 10, 2015 at 8:23
  • 1
    You are not alone my friend. Commented Sep 10, 2015 at 8:31
  • yes seems like 7.1 messes a bit things up. i have the same issue with a code that worked fine with Xcode 7 beta 6 but now doesn't with 7.1
    – Korpel
    Commented Sep 10, 2015 at 8:44
  • Do you think its safe to assume that this is a bug in AFNetworking or is it a bug within the Swift compiler (since it appears to be dealing with messed up ARC code somehow)
    – Tim Specht
    Commented Sep 10, 2015 at 8:50

1 Answer 1

1

To answer my own question and leave this here for anyone out there who might be running into the same problem:

Apparently, the Swift 2.0 compiler doesn't like closures being passed an inout parameter. I had a closure in place which could be used to further customize my request which took an object of type NSMutableURLRequest as an inout parameter. Once changing this closure to simply return the request and removing the inout everything works as expected again ...

1
  • can u tell me what actually u did. i too facing same problem Commented Sep 6, 2016 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.