swiftlang / swift

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

[SR-469] Segmentation fault 11 when extension adds return type or parameter #43086

Closed swift-ci closed 8 years ago

swift-ci commented 8 years ago
Previous ID SR-469
Radar None
Original Reporter chrismanahan (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment Xcode Version 7.2 (7C68) OSX 10.11.1 Mac mini (late 2014) 2.8 ghz intel core i5 8 gb 1600 mhz ddr3 intel iris 1536mb
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash | |Assignee | None | |Priority | Medium | md5: 96c3c6ad784fb0eb81d81fa09a7392c5

Issue Description:

If I create a protocol and then extend it to make default implementations, but I leave out the return type or add/remove a parameter, I would expect compilation error pointing out that the method signature in the extension does not match. Instead, I am getting a Segmentation fault 11.

For example

import UIKit

typealias Filter = CIImage -> CIImage

protocol FilterType {
    static func createFilter(name: String, var params: [String: AnyObject]?) -> Filter
    static func createEmptyFilter() -> Filter
}

extension FilterType {
    static func createEmptyFilter() {   // note that Filter is missing
        return { return $0 }
    }
}

When I build, I get the error `Command failed due to signal: Segmentation fault: 11` with the following dump:

CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
    cd /Users/chrism/Dev/github_chrismanahan/FuncCI
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name FuncCI -Onone -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk -target arm64-apple-ios9.2 -g -module-cache-path /Users/chrism/Library/Developer/Xcode/DerivedData/ModuleCache -Xfrontend -serialize-debugging-options -embed-bitcode-marker -enable-testing -I /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Products/Debug-iphoneos -F /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Products/Debug-iphoneos -c -j4 /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/Source/Filters/Blur.swift /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/Source/Filter.swift /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/ViewController.swift /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/AppDelegate.swift /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/Source/Extensions.swift -output-file-map /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/FuncCI-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/FuncCI.swiftmodule -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-generated-files.hmap -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-own-target-headers.hmap -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-all-target-headers.hmap -Xcc -iquote -Xcc /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-project-headers.hmap -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Products/Debug-iphoneos/include -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/DerivedSources/arm64 -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/DerivedSources -Xcc -DDEBUG=1 -emit-objc-header -emit-objc-header-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/FuncCI-Swift.h -Xcc -working-directory/Users/chrism/Dev/github_chrismanahan/FuncCI

<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)

and

CompileSwift normal arm64 /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/Source/Filter.swift
    cd /Users/chrism/Dev/github_chrismanahan/FuncCI
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/Source/Filters/Blur.swift -primary-file /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/Source/Filter.swift /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/ViewController.swift /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/AppDelegate.swift /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/Source/Extensions.swift -target arm64-apple-ios9.2 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk -I /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Products/Debug-iphoneos -F /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Products/Debug-iphoneos -enable-testing -g -module-cache-path /Users/chrism/Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-generated-files.hmap -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-own-target-headers.hmap -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-all-target-headers.hmap -Xcc -iquote -Xcc /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-project-headers.hmap -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Products/Debug-iphoneos/include -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/DerivedSources/arm64 -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/chrism/Dev/github_chrismanahan/FuncCI -emit-module-doc-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter~partial.swiftdoc -Onone -module-name FuncCI -emit-module-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter~partial.swiftmodule -serialize-diagnostics-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter.dia -emit-dependencies-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter.d -emit-reference-dependencies-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter.swiftdeps -o /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter.o -embed-bitcode-marker

0  swift                    0x000000010288dfbb llvm::sys::PrintStackTrace(__sFILE*) + 43
1  swift                    0x000000010288e6fb SignalHandler(int) + 379
2  libsystem_platform.dylib 0x00007fff87dd552a _sigtramp + 26
3  libsystem_platform.dylib 0x00007fd57d8fffff _sigtramp + 4122127087
4  swift                    0x0000000100b54707 swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitProtocolDecl(swift::ProtocolDecl*) + 999
5  swift                    0x0000000100b51ee5 swift::Lowering::SILGenModule::getWitnessTable(swift::ProtocolConformance*) + 277
6  swift                    0x0000000100ba15b0 (anonymous namespace)::SILGenType::emitType() + 1264
7  swift                    0x0000000100ba104e swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
8  swift                    0x0000000100b29bdb swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 779
9  swift                    0x0000000100b2a790 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 928
10 swift                    0x0000000100b2ab3d swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 109
11 swift                    0x000000010097e992 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 11442
12 swift                    0x000000010097bad3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2691
13 swift                    0x0000000100978154 main + 2324
14 libdyld.dylib            0x00007fff8f00c5ad start + 1
15 libdyld.dylib            0x0000000000000041 start + 1895774869
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/Source/Filters/Blur.swift -primary-file /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/Source/Filter.swift /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/ViewController.swift /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/AppDelegate.swift /Users/chrism/Dev/github_chrismanahan/FuncCI/FuncCI/Source/Extensions.swift -target arm64-apple-ios9.2 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk -I /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Products/Debug-iphoneos -F /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Products/Debug-iphoneos -enable-testing -g -module-cache-path /Users/chrism/Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-generated-files.hmap -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-own-target-headers.hmap -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-all-target-headers.hmap -Xcc -iquote -Xcc /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/FuncCI-project-headers.hmap -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Products/Debug-iphoneos/include -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/DerivedSources/arm64 -Xcc -I/Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/chrism/Dev/github_chrismanahan/FuncCI -emit-module-doc-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter~partial.swiftdoc -Onone -module-name FuncCI -emit-module-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter~partial.swiftmodule -serialize-diagnostics-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter.dia -emit-dependencies-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter.d -emit-reference-dependencies-path /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter.swiftdeps -o /Users/chrism/Library/Developer/Xcode/DerivedData/FuncCI-dobenrododlepqbjmgprfxlhkbmj/Build/Intermediates/FuncCI.build/Debug-iphoneos/FuncCI.build/Objects-normal/arm64/Filter.o -embed-bitcode-marker 

About 30% of the time, Xcode will crash after I build (and get a seg fault) then try to navigate to another file

belkadan commented 8 years ago

Fixed in GitHub master.