Swift runtime crash when closure passed as @noescape is mistakenly identified as having escaped (Nimble)

Originator:benchatelain
Number:rdar://40857699 Date Originated:2018-06-06
Status:Open Resolved:
Product:macOS SDK / Something not on this list Product Version:Xcode 10.0 beta 1 (10L176w), Default Swift toolchain
Classification:Bug, Crash/Hang/Data Loss Reproducible:Always
 
Summary:
Running the test suite for the Nimble testing framework (at commit f875d73fc22b388bce9cefe405c92d0b98dc0e6c, master as of 2018-06-06)
causes the following runtime exception:

Thread 1: closure argument passed as @noescape to Objective-C has escaped: file /Users/phatblat/dev/ios/pods/Nimble/Sources/Nimble/DSL+Wait.swift, line 57, column 38

screenshot:
https://user-images.githubusercontent.com/909674/41007167-68dd1b2c-68d9-11e8-8313-abbe980eecb6.png

https://github.com/Quick/Nimble/blob/master/Sources/Nimble/DSL%2BWait.swift#L57

Steps to Reproduce:
1. Clone the Nimble framework from GitHub
2. Check out the master branch (commit f875d73fc22b388bce9cefe405c92d0b98dc0e6c)
3. Run the test suite

Expected Results:
The test suite completes successfully.

Actual Results:
The test suite fails to complete due to the following runtime exception:

Thread 1: closure argument passed as @noescape to Objective-C has escaped: file /Users/phatblat/dev/ios/pods/Nimble/Sources/Nimble/DSL+Wait.swift, line 57, column 38

Version/Build:
Xcode 10.0 beta 1 (10L176w)
OS X 10.13.5 (17F77)

Configuration: (hardware)
MacBook 12-inch (MacBook8,1), Early 2015

Workaround:
WWDC Lab engineers suggested removing the  __attribute__((noescape)) from the Objective-C declaration and implementation and adding @escaping on the Swift side where the closure is passed in.

Comments


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!