Skip to content

[SR-4622] App crashes when Swift optimization is selected. #47199

Closed
@swift-ci

Description

@swift-ci
Previous ID SR-4622
Radar None
Original Reporter babt (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode Version 8.3.1 (8E1000a) with Swift 3.1. macOS 10.12.4 (16E195) iOS 10.3.1 (14E304)

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, OptimizedOnly, RunTimeCrash
Assignee None
Priority Medium

md5: 35d418a7d55b30a2e90acddf9695618d

Issue Description:

The attached Xcode project provides a simple test case. If this app is built without optimization it runs as expected. However, when built using either single file optimization or whole module optimization, the app crashes attempting to convert a Swift.Error to an NSError using the swift_bridgeErrorToNSError() method.

Although this test case does not use any Obj-C code, some of the test classes being used to illustrate the problem were derived from a significantly larger app that does have some Obj-C in it and is running into the same problem.

Removal of the @objc decoration from the "RequestManager" class and it's delegate protocol "fixes" the problem. This is ok for this particular test case but in the larger app that this was derived from, that decoration is required as the real "RequestManager" and it's delegate are used by existing Objective-C code.

Steps to Reproduce:

  1. Install Xcode 8.3.1
  2. Unzip OptimizerTest.zip
  3. Open the OptimizerTest.xcodeproj
  4. Compile and run the app in either the simulator or on a device.

Expected Results:
"Invalid response" printed on the debug console via an NSLog statement.

Actual Results:
Application crashes with following trace:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareoptimized onlyFlag: An issue whose reproduction requires optimized compilationrun-time crashBug → crash: Swift code crashed during execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions