Open
Description
I've discovered a pretty serious issue in Bolts 1.8.4 while in the process of converting my projects over to Swift 3.
Setting an optional class reference as the result of of a BFTaskCompletionSource will cause an EXC_BAD_ACCESS(code=1) on objc_object::release().
This can be replicated using the following code snippet and calling "crash()"
func crash() {
self.optionalStringTask().continue({ (task) -> Any? in
return self.optionalStringTask()
})
}
func optionalStringTask() -> BFTask<AnyObject> {
let completionSource = BFTaskCompletionSource<AnyObject>()
DispatchQueue.main.asyncAfter(deadline: DispatchTime(uptimeNanoseconds: 1 * NSEC_PER_SEC)) {
let optionalString: NSString? = "AN OPTIONAL STRING THAT SHOULD NOT CRASH"
completionSource.setResult(optionalString)
}
return completionSource.task
}
I've attached a sample stack trace of the main thread below.
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x000000018a325704 in objc_object::release() ()
#1 0x00000001000e02c0 in -[BFTask .cxx_destruct] at /Users/jackson.beachwood/Documents/Development/Source/Projects/Demonstrations/BoltsCrashTest/Pods/Bolts/Bolts/Common/BFTask.m:48
#2 0x000000018a30af10 in object_cxxDestructFromClass(objc_object*, objc_class*) ()
#3 0x000000018a3176e0 in objc_destructInstance ()
#4 0x000000018a317744 in object_dispose ()
#5 0x00000001000e0a18 in -[BFTaskCompletionSource .cxx_destruct] at /Users/jackson.beachwood/Documents/Development/Source/Projects/Demonstrations/BoltsCrashTest/Pods/Bolts/Bolts/Common/BFTaskCompletionSource.m:26
#6 0x000000018a30af10 in object_cxxDestructFromClass(objc_object*, objc_class*) ()
#7 0x000000018a3176e0 in objc_destructInstance ()
#8 0x000000018a317744 in object_dispose ()
#9 0x00000001000542c0 in ___lldb_unnamed_symbol2$$BoltsCrashTest ()
#10 0x00000001000543b0 in block_destroy_helper.5 ()
#11 0x000000018a7b2a28 in _Block_release ()
#12 0x000000010089d21c in _dispatch_client_callout ()
#13 0x00000001008a2284 in _dispatch_main_queue_callback_4CF ()
#14 0x000000018b881f2c in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#15 0x000000018b87fb18 in __CFRunLoopRun ()
#16 0x000000018b7ae048 in CFRunLoopRunSpecific ()
#17 0x000000018d231198 in GSEventRunModal ()
#18 0x0000000191780818 in -[UIApplication _run] ()
#19 0x000000019177b550 in UIApplicationMain ()
#20 0x0000000100055684 in main at /Users/jackson.beachwood/Documents/Development/Source/Projects/Demonstrations/BoltsCrashTest/BoltsCrashTest/AppDelegate.swift:12
#21 0x000000018a7905b8 in start ()
Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial)
#0 0x00000001008a8ba4 in _dispatch_queue_push ()
#1 0x000000010067d4d8 in DispatchQueue.asyncAfter(wallDeadline : DispatchWallTime, qos : DispatchQoS, flags : DispatchWorkItemFlags, execute : @convention(block) () -> ()) -> () ()
#2 0x0000000100053fe8 in ViewController.optionalStringTask() -> BFTask<AnyObject> at /Users/jackson.beachwood/Documents/Development/Source/Projects/Demonstrations/BoltsCrashTest/BoltsCrashTest/ViewController.swift:30
#3 0x0000000100053b24 in ViewController.crash() -> () at /Users/jackson.beachwood/Documents/Development/Source/Projects/Demonstrations/BoltsCrashTest/BoltsCrashTest/ViewController.swift:20
#4 0x0000000100053a4c in ViewController.viewDidLoad() -> () at /Users/jackson.beachwood/Documents/Development/Source/Projects/Demonstrations/BoltsCrashTest/BoltsCrashTest/ViewController.swift:16
#5 0x0000000100053ad8 in @objc ViewController.viewDidLoad() -> () ()
#6 0x00000001917155c8 in -[UIViewController loadViewIfRequired] ()
#7 0x0000000191715190 in -[UIViewController view] ()
#8 0x000000019171b93c in -[UIWindow addRootViewControllerViewIfPossible] ()
#9 0x0000000191718ddc in -[UIWindow _setHidden:forced:] ()
#10 0x000000019178b604 in -[UIWindow makeKeyAndVisible] ()
#11 0x0000000191997f80 in -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] ()
#12 0x000000019199dad0 in -[UIApplication _runWithMainScene:transitionContext:completion:] ()
#13 0x00000001919b2270 in __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3134 ()
#14 0x000000019199aab4 in -[UIApplication workspaceDidEndTransaction:] ()
#15 0x000000018d475904 in __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ ()
#16 0x000000018d475770 in -[FBSSerialQueue _performNext] ()
#17 0x000000018d475b18 in -[FBSSerialQueue _performNextFromRunLoopSource] ()
#18 0x000000018b882278 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#19 0x000000018b881bc0 in __CFRunLoopDoSources0 ()
#20 0x000000018b87f7c0 in __CFRunLoopRun ()
#21 0x000000018b7ae048 in CFRunLoopRunSpecific ()
#22 0x00000001917807cc in -[UIApplication _run] ()
#23 0x000000019177b550 in UIApplicationMain ()
#24 0x0000000100055684 in main at /Users/jackson.beachwood/Documents/Development/Source/Projects/Demonstrations/BoltsCrashTest/BoltsCrashTest/AppDelegate.swift:12
#25 0x000000018a7905b8 in start ()
Metadata
Metadata
Assignees
Labels
No labels