swiftlang / swift

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

[SR-8149] NSPasteboard.PasteboardType.findPanelSearchOptions crashes compiler #50681

Open amomchilov opened 6 years ago

amomchilov commented 6 years ago
Previous ID SR-8149
Radar rdar://problem/41725279
Original Reporter @amomchilov
Type Bug

Attachment: Download

Environment Minimal example project attached. CompilerCrash.zip Uncomment `ViewController.swift:16` and compile. This bug exists in at least following toolchains: 1. `Xcode 9` 2. `Xcode 10.0 Beta 2 (10L177m)` 3. `Swift 4.2 Snapshot 2018-06-26 (a)`
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash, Serialization | |Assignee | None | |Priority | Medium | md5: cf2c2c0df41eaefd83c5d90fd9114aa5

relates to:

Issue Description:

Any reference to NSPasteboard.PasteboardType.findPanelSearchOptions crashes the compiler. All other cases of the same enum seem to work fine.

 <unknown>:0: error: fatal error encountered while reading from module 'CompilerCrash'; please file a bug report with your project and the crash log
 * 
 ** 
 *** DESERIALIZATION FAILURE (please include this section in any bug report) ***
 result is ambiguous
 0 swift 0x0000000111fa7b48 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
 1 swift 0x0000000111fa6d87 llvm::sys::RunSignalHandlers() + 39
 2 swift 0x0000000111fa81c2 SignalHandler(int) + 258
 3 libsystem_platform.dylib 0x00007fff57689d3a _sigtramp + 26
 4 libsystem_platform.dylib 000000000000000000 _sigtramp + 2828493536
 5 libsystem_c.dylib 0x00007fff5754b09d abort + 127
 6 swift 0x000000010f700b80 swift::ModuleFile::fatal(llvm::Error) + 704
 7 swift 0x000000010f7010bd swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 157
 8 swift 0x000000010f7272a4 swift::SILDeserializer::readGlobalVar(llvm::StringRef) + 1796
 9 swift 0x000000010f73751a swift::SILDeserializer::getAllSILGlobalVariables() + 74
 10 swift 0x000000010f7b93c7 swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 135
 11 swift 0x000000010e796284 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 12868
 12 swift 0x000000010e792022 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2962
 13 swift 0x000000010e74cc8e main + 1134
 14 libdyld.dylib 0x00007fff5748fb11 start + 1
 15 libdyld.dylib 0x000000000000003f start + 2830566703
 Stack dump:
 0. Program arguments: /Library/Developer/Toolchains/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-26-a.xctoolchain/usr/bin/swift -frontend -merge-modules -emit-module /Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/Objects-normal/x86_64/ViewController~partial.swiftmodule /Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/Objects-normal/x86_64/Crash~partial.swiftmodule /Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/Objects-normal/x86_64/AppDelegate~partial.swiftmodule -parse-as-library -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-apple-macosx10.13 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Products/Debug -F /Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Products/Debug -enable-testing -g -module-cache-path /Users/Alex/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -I/Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/CompilerCrash-generated-files.hmap -Xcc -I/Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/CompilerCrash-own-target-headers.hmap -Xcc -I/Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/CompilerCrash-all-target-headers.hmap -Xcc -iquote -Xcc /Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/CompilerCrash-project-headers.hmap -Xcc -I/Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Products/Debug/include -Xcc -I/Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/DerivedSources/x86_64 -Xcc -I/Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/Alex/Desktop/CompilerCrash -emit-module-doc-path /Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/Objects-normal/x86_64/CompilerCrash.swiftdoc -emit-objc-header-path /Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/Objects-normal/x86_64/CompilerCrash-Swift.h -module-name CompilerCrash -o /Users/Alex/Library/Developer/Xcode/DerivedData/CompilerCrash-goasxzodyhnihzfejnfdcrxnzfgt/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/Objects-normal/x86_64/CompilerCrash.swiftmodule 
 1. While deserializing SIL global "NSFindPanelSearchOptionsPboardType"
 error: Abort trap: 6
amomchilov commented 6 years ago

Same error output, but caused by a different imported API. It's been resolved, but its solution doesn't fix this issue

belkadan commented 6 years ago

Yeah, SR-7879 was a narrow fix. We've done some more general work since then, so this might be fixed by now as well. I'll take a look.

@swift-ci create

belkadan commented 6 years ago

Nope, different issue, caused by AppKit having both NSFindPanelSearchOptionsPboardType and NSPasteboardTypeFindPanelSearchOptions.

amomchilov commented 6 years ago

@belkadan Hey Jordan, do you have a fix in mind?

belkadan commented 6 years ago

I'm talking with AppKit. Meanwhile, you can either keep compiling in Swift 4 mode, or write a little Objective-C helper function that returns the constant rather than going through the property.