Cast to String crashes, but only in Release mode when underlying representation is _TtCSs19_NSContiguousString

Originator:chris.lozach
Number:rdar://20017939 Date Originated:3/2/2015
Status:Closed Resolved:
Product:iOS Product Version:8.0
Classification:Crash/Hang/Data Loss Reproducible:Always
 
[Update from Apple: "There are no plans to address this. We are now closing this report."]

If you have questions about the resolution, or if this is still a critical issue for you, then please update your bug report with that information.

Summary:
This bit us in the latest release of ActiveHours (v.3.3). It's unclear to us how it passed our testing...perhaps we never tested the exact code path in Release mode...but as soon as it made it into customers hands, we experienced a high volume of reproducible crashes!

Quick side note: if you have _any_ sway with the iTunes Connect team, we'd really appreciate getting v.3.4 reviewed and in customers' hands ASAP! The only change in that build is adding the .stringValue method, per "Workaround 3" in the attached sample project.

Anyway, the root of the issue is all in the title. I don't know enough about the inner workings of Swift & the Foundation framework to say more here, but I've provided very detailed findings in the sample project's ViewController.swift comments.

Steps to Reproduce:
1. Unzip the attached SwiftyCrasher.zip
2. Check out the "crash" branch in git
3. Open the sample project in Xcode 6.1.1
4. Verify that the scheme Build Configuration is set to Release
5. Run

Expected Results:
App should not crash (or, minimally, should fail equally in Debug mode)

By way of investigation, try the 3 "workaround" branches. As far as I can tell, this is either a Swift 1.1 bug, a Foundation bug, or some combination of both.

Actual Results:
App crashes in Release mode, but works just fine in Debug mode.

Version:
iOS 7.0+

Notes:


Configuration:
Xcode 6.1.1, Simulator or on-device

[Email me at chris.lozach@activehours.com if you would like a copy of the sample project that illustrates this bug.]

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!