EXC_BAD_INSTRUCTION in cancel disk retrieve task by using dispatch_block_cancel

Originator:onevcat
Number:rdar://22432170 Date Originated:26-Aug-2015
Status:Resolved Resolved:YES
Product:iOS SDK Product Version:iOS SDK 9
Classification: Reproducible:Always
 
Summary:
The lib dispatch crashes on from Xcode 7 beta 6 on canceling a block.

Steps to Reproduce:
1. Create a new iOS app in Swift project in Xcode 7 beta 6.
2. Copy & paste the code snippet below to the application:didFinishLaunchingWithOptions: method in AppDelegate:

        let block = dispatch_block_create(DISPATCH_BLOCK_INHERIT_QOS_CLASS) { () -> Void in
            print("Hello world")
        }
        
        dispatch_async(dispatch_get_main_queue(), block)
        dispatch_block_cancel(block)

3. Run.

Expected Results:
App can be launched correctly, and nothing will be printed out in the console since the block is cancelled.

Actual Results:
Crash with a EXC_BAD_INSTRUCTION on the line of "dispatch_block_cancel"

Version:
8.1, 8.4, 9.0

Notes:
The attached files show screenshots when the crash happens

Configuration:
iPhone 6 Plus, iPhone Simulator from 8.1 to 9.0

Comments

Fixed

It is fixed in Xcode 7.1 beta 2 (7B75)

Apple Developer Relations24-Sep-2015 06:42 AM

Engineering has provided the following feedback regarding this issue:

Please verify this issue with the latest Xcode 7.1 beta 2 and update your bug report with your results.

If you still have any issues, please provide any relevant logs or information that could help us further investigate.

Xcode 7.1 beta 2 - 7B75 https://developer.apple.com/xcode/downloads/

Please let us know whether the issue is resolved for you by updating your bug report.

Seeing same thing XCode 7.1 beta (7b60) iOS 9.1

This still happens in Xcode 7.

This still happens in Xcode 7 GM


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!