[SR-4622] App crashes when Swift optimization is selected. #47199
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler 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
Xcode Version 8.3.1 (8E1000a) with Swift 3.1. macOS 10.12.4 (16E195) iOS 10.3.1 (14E304)
Additional Detail from JIRA
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:
Expected Results:
"Invalid response" printed on the debug console via an NSLog statement.
Actual Results:
Application crashes with following trace:
thread Redundant Load Elimination Patches #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x0000000104861e72 libobjc.A.dylib`objc_class::demangledName(bool) + 40
frame Redundant Load Elimination Patches #1: 0x00000001067949ad libswiftCore.dylib`swift::nameForMetadata(swift::TargetMetadata<swift::InProcess> const*, bool) + 125
frame Remove unnecessary
unsafeUnwrap
calls. #2: 0x0000000106794c51 libswiftCore.dylib`swift_getTypeName + 401frame Initial implementation of a @_cdecl attribute to export top-level functions to C #3: 0x000000010426a94c OptimizerTest`specialized (_adHocPrint_unlocked<A, B where ...> (A, Mirror, inout B, isDebugPrint : Bool) -> ()).(printTypeName Redundant Load Elimination Patches #1)<A, B where ...> (Any.Type) -> () at RequestManager.swift:0 [opt]
frame install Foundation via the ninja script and add the test phase for Foundation #4: 0x000000010426dcb8 OptimizerTest`specialized specialized _adHocPrint_unlocked<A, B where ...> (A, Mirror, inout B, isDebugPrint : Bool) -> () at RequestManager.swift:0 [opt]
frame Only run bindings-build-record on OS X due to test flakiness on Liunx… #5: 0x000000010426a1d9 OptimizerTest`specialized _debugPrint_unlocked<A, B where ...> (A, inout B) -> () [inlined] generic specialization <OptimizerTest.RequestManager.Error.Type, Swift.String with Swift.String : Swift.TextOutputStream in Swift> of Swift._adHocPrint_unlocked <A, B where B: Swift.TextOutputStream> (A, Swift.Mirror, inout B, isDebugPrint : Swift.Bool) -> () at RequestManager.swift:0 [opt]
frame Debug Info: Don't reset the debug scope after leaving the outermost s… #6: 0x000000010426a1bf OptimizerTest`specialized _debugPrint_unlocked<A, B where ...> (A, inout B) -> () at RequestManager.swift:0 [opt]
frame Fix a bug in SILValue's hoistAddressProjections #7: 0x000000010426877e OptimizerTest`protocol witness for Error._domain.getter in conformance RequestManager.Error [inlined] generic specialization <OptimizerTest.RequestManager.Error.Type> of Swift.String.init <A> (reflecting : A) -> Swift.String at RequestManager.swift:0 [opt]
frame Simplify configure pass for Foundation to use a defined variable for XCTest's build directory #8: 0x0000000104268779 OptimizerTest`protocol witness for Error._domain.getter in conformance RequestManager.Error [inlined] generic specialization <OptimizerTest.RequestManager.Error with OptimizerTest.RequestManager.Error : Swift.Error in OptimizerTest> of (extension in Swift):Swift.Error._domain.getter : Swift.String at RequestManager.swift:0 [opt]
frame update related projects list to include Foundation and XCTest #9: 0x0000000104268779 OptimizerTest`protocol witness for Error._domain.getter in conformance RequestManager.Error at RequestManager.swift:0 [opt]
frame Remove the FunctionEnumeration data structure from CalleeAnalysis #10: 0x00000001065ec2ee libswiftCore.dylib`swift_stdlib_getErrorDomainNSString + 78
frame Alias analysis cleanups #11: 0x00000001067c868c libswiftCore.dylib`swift_bridgeErrorToNSError(swift::SwiftError*) + 284
frame Add support to create xctoolchain with code sign #12: 0x000000010426fdb7 OptimizerTest`specialized RequestManager.(self=<unavailable>, error=0x00006300000b7ca0) -> ()).(closure Redundant Load Elimination Patches #1) at RequestManager.swift:141 [opt]
frame Use typed boxes to simplify capture representation in SILGen #13: 0x000000010426f778 OptimizerTest`partial apply for RequestManager.(startSession() -> ()).(closure Redundant Load Elimination Patches #1) [inlined] OptimizerTest.RequestManager.(startSession () -> ()).(closure Redundant Load Elimination Patches #1) at RequestManager.swift:0 [opt]
frame Reduce memory footprint of the Swift compiler #14: 0x000000010426f76d OptimizerTest`partial apply for RequestManager.(startSession() -> ()).(closure Redundant Load Elimination Patches #1) at RequestManager.swift:0 [opt]
frame Remove conditional compilation of tvOS #15: 0x00000001083f44a6 libdispatch.dylib`_dispatch_call_block_and_release + 12
frame Added a link to Testing.rst in the readme file #16: 0x000000010841d05c libdispatch.dylib`_dispatch_client_callout + 8
frame Fix the license #17: 0x00000001083fe40b libdispatch.dylib`_dispatch_main_queue_callback_4CF + 411
frame Fix URL for apple/swift-cmark #18: 0x000000010748e909 CoreFoundation`CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
frame Fix typo in docs/ARCOptimization.rst #19: 0x0000000107454ae4 CoreFoundation`__CFRunLoopRun + 2164
frame [README] syntax highlighting! #20: 0x0000000107454016 CoreFoundation`CFRunLoopRunSpecific + 406
frame converted ApiNotes Readme.txt to markdown #21: 0x00000001093d4a24 GraphicsServices`GSEventRunModal + 62
frame Remove extra / in git commands in README #22: 0x0000000104d2c0d4 UIKit`UIApplicationMain + 159
frame Fix typo #23: 0x0000000104268e60 OptimizerTest`main at AppDelegate.swift:12 [opt]
frame updated spelling mistake of instead #24: 0x000000010846965d libdyld.dylib`start + 1
(
The text was updated successfully, but these errors were encountered: