[Swift] dispatch_block_t re-audit causes GCD APIs to crash

Originator:zwaldowski
Number:rdar://22437691 Date Originated:26-Aug-2015 11:39 AM
Status:Open Resolved:true
Product:Developer Tools Product Version:Xcode 7.0 beta 6 (7A192o), swiftlang-700.0.57.3, clang-700.0.72
Classification:Serious Bug Reproducible:Always
 
Summary:
In order to use the GCD features introduced in iOS 8/Mac OS X 10.10 such as QoS overrides, dispatch_block_notify, and dispatch_block_create, you must create a wrapper block using dispatch_block_create. This creates extra side-table data in the normal block structure.

Steps to Reproduce:
1. Use dispatch_block_create.
2. Pass the created block to dispatch_block_notify.
3. Run the code.

Expected Results:
Upon calling dispatch_block_notify, the given function will be submitted to the given queue once the original block is called.

Actual Results:
Upon calling dispatch_block_notify, the application traps inside GCD with "BUG IN CLIENT OF LIBDISPATCH: Invalid block object passed to dispatch_block_notify()".

Version:
Xcode 7.0 beta 6 (7A192o), swiftlang-700.0.57.3, clang-700.0.72

Notes:
The audit for dispatch_block_t appears to have removed @convention(block) in Beta 6. ARC, appears to copy the block such that the side-table is discarded.

Configuration:
Occurs with any use a wrapped dispatch_block_t.

Attachments:
'BlockProblems.playground.zip' was successfully uploaded.

Comments

This is fixed in Xcode 7.1 beta 2.

Update from Apple Developer Bug Reporting 2015-09-15

Engineering has determined that your bug report (22437691) is a duplicate of another issue (22432170) and will be closed.

By zwaldowski at Sept. 15, 2015, 4:19 a.m. (reply...)

Twitter updates from Joe Groff on 2015-09-10

@zwaldowski We're working on a fix but it didn't make it in time for GM, sorry! (https://twitter.com/jckarter/status/641963176335032320)

@zwaldowski You might be able to work around it by wrapping affected functions in ObjC with versions that take 'id' in your bridging header. (https://twitter.com/jckarter/status/641963107225501696)

By jeremyw.sherman at Sept. 10, 2015, 3:31 p.m. (reply...)

Similar issue

A similar issue was reported here as well: https://openradar.appspot.com/radar?id=6663758294286336

Referenced 'BlockProblems.playground.zip': https://drive.google.com/a/bignerdranch.com/file/d/0B3FglI-wO7EqajVUQTlZZ3EzSlE/view?usp=sharing

By zwaldowski at Aug. 26, 2015, 3:43 p.m. (reply...)

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!