[SR-10444] Xcode 10.2 Generates Crashing Code in particular circumstance involving structs, optionals, and file-scoped arrays #52844
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
crash
Bug: A crash, i.e., an abnormal termination of software
optimized only
Flag: An issue whose reproduction requires optimized compilation
run-time crash
Bug → crash: Swift code crashed during execution
Attachment: Download
Environment
$ uname -v
Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64
$ swift --version
Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Additional Detail from JIRA
md5: c20885eef3ecc58cf89fd73240e1b6c0
Issue Description:
Note: Also reported in Radar 49755264
Summary:
New in Xcode 10.2 when generating Swift 4.2 Release code for ARM (e.g. iPhone 6s or iPhone XR) OR iPhone Simulator, the app containing code shown below crashes.
The same code DOES NOT crash when built by swift shipped in Xcode 10.1
The code requires repeated assignment to an array field inside the optional struct `var` property of a class.
I winnowed this down as much as I could, but as far as I can tell all the weird things in the example code are required : the global scope array, the struct, the optional var instance of the struct, and calling the function "sometime later".
Steps to Reproduce:
Here is the code, or simply unzip attached swift package build-and-run, making sure to select Release configuration for your Run target.
Expected Results:
It should print "Bug Fixed"
Actual Results:
It crashes
xcode_10_2_crash(15484,0x1004d55c0) malloc: *** error for object 0x7fcec7605990: pointer being freed was not allocated
Version/Build:
Xcode 10.2 (10E125)
Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0
Configuration:
Xcode 10.2
Swift 4.2 OR Swift 5
Release Build
The text was updated successfully, but these errors were encountered: