The application crashes when calling this function in the Release assembly (for Debug, it works flawlessly)
func crashMe()
{
func crashHelper(str: String) {}
var crashString = "123"
crashString.remove(at: crashString.startIndex)
crashHelper(str: "\(crashString)")
crashString.data(using: .ascii)
}
Almost always plays on a real device and often on a simulator (but not 100%) with iOS 9 or 10
Removing any row from this function prevents a crash
What am I doing wrong or maybe it's a Swift bug?
It can crash in different places, one of the crash logs:
0x02194b8a in swift_unknownRelease ()
0x020702c5 in _NSContiguousString .__ deallocating_deinit ()
0x024cea26 in String.data (using: String.Encoding, allowLossyConversion: Bool) -> Data? ()
0x0007e04f in the specialized application AppDelegate.crashMe () → ()
0x0007c31c in AppDelegate.crashMe () → () [inlined] ()