swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.3k stars 10.34k forks source link

[SR-4577] optimization breaks String bridging? #47154

Open dabrahams opened 7 years ago

dabrahams commented 7 years ago
Previous ID SR-4577
Radar rdar://problem/31603112
Original Reporter @dabrahams
Type Bug
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, OptimizedOnly | |Assignee | @bob-wilson | |Priority | Medium | md5: 1ff823a255c5ef471103ec868016b2d6

Issue Description:

$ git fetch https://github.com/dabrahams/swift refs/bugs/optimization-breaks-bridging:BUG && git checkout BUG~

build and test as follows:

build-script --skip-build-ios-device --skip-build-tvos-device --skip-build-compiler-rt --skip-build-benchmarks --release --no-assertions --test

Many tests, all involving bridging Strings to Objective-C, will fail with a crash. This only occurs in release builds. Checking out "BUG" instead of "BUG\~" will suppress the failures. The difference between "BUG" and "BUG\~" should be a semantics-preserving change, and there's truly no reason it would affect only Objective-C-related files.

FAIL: Swift(macosx-x86_64) :: Interpreter/SDK/Foundation_bridge.swift (87 of 3460)
FAIL: Swift(macosx-x86_64) :: Interpreter/SDK/Foundation_NSLocalizedString.swift (88 of 3460)
FAIL: Swift(macosx-x86_64) :: Interpreter/imported_objc_generics.swift (89 of 3460)
FAIL: ["InheritInSwift", "BridgedInitializer"]
FAIL: Swift(macosx-x86_64) :: Interpreter/SDK/objc_bridge_cast.swift (91 of 3460)
FAIL: Swift(macosx-x86_64) :: Interpreter/SDK/objc_dynamic_lookup.swift (92 of 3460)
FAIL: Swift(macosx-x86_64) :: Interpreter/SDK/archiving_generic_swift_class.swift (93 of 3460)
FAIL: Swift(macosx-x86_64) :: Interpreter/SDK/objc_fast_enumeration.swift (94 of 3460)
FAIL: Swift(macosx-x86_64) :: Interpreter/SDK/Foundation_test.swift (95 of 3460)
FAIL: ["NSString", "NSMutableArray", "rdar://17584531", "NSKeyedUnarchiver/decodeObjectOfClass(_:forKey:)", "NSKeyedUnarchiver/decodeTopLevel*", "NotificationCenter/addObserver(_:selector:name:object:)"]
FAIL: Swift(macosx-x86_64) :: Interpreter/SDK/Foundation_NSString.swift (96 of 3460)
FAIL: Swift(macosx-x86_64) :: Interpreter/SDK/objc_keypath.swift (97 of 3460)
FAIL: Swift(macosx-x86_64) :: Interpreter/SDK/objc_switch.swift (98 of 3460)
...

Other hashes

clang                              5b642bad4e Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
cmark                              d875488 Merge pull request #​4 from llvm-beanz/generate-cmark-exports
compiler-rt                        fef6bcb58 Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
llbuild                            4eedf61 Merge pull request #​138 from ddunbar/dep-scan-order
lldb                               e9bfbd6d3 Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
llvm                               90ddc086b8f Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
Traceback (most recent call last):

@swift-ci create

dabrahams commented 7 years ago

@swift-ci create

dabrahams commented 7 years ago

I think I may have found the bug in my code that accounts for this. Will confirm shortly.