Open swift-ci opened 7 years ago
@swift-ci create
papierschiff (JIRA User) In swift, global initializers run at an unspecified point before the first use of a global initializer. What is happening here is that the optimizer is taking advantage of this behavior to hoist the invocation of the global initializer in enumVar so that it is unconditional. This causes the global initializer for mySubClass to be called re-entrantly which causes dispatch_once to crash. This results in the program being illegal.
Attachment: Download
Environment
- crash: Xcode 8.3 (8E162); macOS 10.12.4 (16E195) - no crash: Xcode 8.2; macOS 10.12.4 (16E195) - endless loop: swift-3.0.2-RELEASE; ubuntu16.04Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, 3.1Regression, OptimizedOnly, RunTimeCrash | |Assignee | None | |Priority | Medium | md5: 259fbacaf2f7da0b69fb8a7b24b2b58fIssue Description:
The following code crashs, but only with -O or -O -whole-module-optimization. It crashs on linux and macOS
The code works fine without optimization.
stacktrace: