Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-4210] Segmentation Fault: 11 Using Protocol w/ associatedType w/ Class Constraint #46793

Closed
swift-ci opened this issue Mar 9, 2017 · 8 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Mar 9, 2017

Previous ID SR-4210
Radar rdar://problem/30976603
Original Reporter michael (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Version 8.3 beta 4 (8W143q)
Toolchain: Swift Development Snapshot 2017-03-08 (a)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 3.1Regression, CompilerCrash
Assignee None
Priority Medium

md5: 1871cd607a6c6bb829baefe94aba24ab

Issue Description:

Using the latest Swift 3.1 Snapshot at the time of this writing (2017-03-08 (a)) and Xcode 8.3 beta 4, a "Segmentation Fault: 11" error occurs with the following code.

/// A simple `class` type used to constrain the collection’s element type. Any existing class will do, e.g. `NSError`.
class Object { }

/// A protocol for `Object` collection types.
protocol ObjectCollectionProtocol {
    associatedtype Element: Object
}

/// A concrete implementation of `ObjectCollectionProtocol`.
final class ObjectCollection<T: Object>: ObjectCollectionProtocol {
    typealias Element = T
    
    /// This initializer’s signature creates a "Segmentation fault: 11" error.
    init<C: ObjectCollectionProtocol>(_ baseCollection: C) where C.Element == T { }
}

This does not occur in some earlier snapshots, or earlier versions of Swift. Note that this is a very isolated example of the same error I experience trying to build Realm, specifically at the initializer here.

The error details from the snippet above in the "SegFault11" project in SegFault11.swift (attached):

CompileSwift normal x86_64 /Users/Michael/Desktop/SegFault11/SegFault11/SegFault11.swift
    cd /Users/Michael/Desktop/SegFault11
    /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2017-03-08-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/Michael/Desktop/SegFault11/SegFault11/SegFault11.swift /Users/Michael/Desktop/SegFault11/SegFault11/ViewController.swift /Users/Michael/Desktop/SegFault11/SegFault11/AppDelegate.swift -target x86_64-apple-ios10.3 -enable-objc-interop -sdk "/Users/Michael/Downloads/Xcode-beta 2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk" -I /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Products/Debug-iphonesimulator -F /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/Michael/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/SegFault11-generated-files.hmap -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/SegFault11-own-target-headers.hmap -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/SegFault11-all-target-headers.hmap -Xcc -iquote -Xcc /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/SegFault11-project-headers.hmap -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/DerivedSources/x86_64 -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/Michael/Desktop/SegFault11 -emit-module-doc-path /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11~partial.swiftdoc -serialize-diagnostics-path /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11.dia -Onone -module-name SegFault11 -emit-module-path /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11~partial.swiftmodule -emit-dependencies-path /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11.d -emit-reference-dependencies-path /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11.swiftdeps -o /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11.o

0  swift                    0x0000000111f85898 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000111f84ab6 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x0000000111f85ee9 SignalHandler(int) + 361
3  libsystem_platform.dylib 0x00007fffa26fbbba _sigtramp + 26
4  libsystem_platform.dylib 0x00007fa4541d1590 _sigtramp + 2980927984
5  swift                    0x000000010fdc132c swift::GenericSignatureBuilder::addSameTypeRequirementBetweenArchetypes(swift::GenericSignatureBuilder::PotentialArchetype*, swift::GenericSignatureBuilder::PotentialArchetype*, swift::GenericSignatureBuilder::RequirementSource const*) + 1612
6  swift                    0x000000010fdbbef6 swift::GenericSignatureBuilder::addSameTypeRequirement(swift::GenericSignatureBuilder::ResolvedType, swift::GenericSignatureBuilder::ResolvedType, swift::GenericSignatureBuilder::FloatingRequirementSource, llvm::function_ref<void (swift::Type, swift::Type)>) + 102
7  swift                    0x000000010fdbf91c swift::GenericSignatureBuilder::addRequirement(swift::Requirement const&, swift::GenericSignatureBuilder::FloatingRequirementSource, swift::SubstitutionMap const*, llvm::SmallPtrSetImpl<swift::ProtocolDecl*>&) + 924
8  swift                    0x000000010fdbfd92 swift::GenericSignatureBuilder::addRequirement(swift::RequirementRepr const*, swift::GenericSignatureBuilder::FloatingRequirementSource, swift::SubstitutionMap const*) + 834
9  swift                    0x000000010fdc224a swift::GenericSignatureBuilder::addRequirement(swift::RequirementRepr const*) + 90
10 swift                    0x000000010fc8ab3b swift::TypeChecker::checkGenericParamList(swift::GenericSignatureBuilder*, swift::GenericParamList*, swift::GenericSignature*, swift::GenericTypeResolver*) + 459
11 swift                    0x000000010fc8b99b checkGenericFuncSignature(swift::TypeChecker&, swift::GenericSignatureBuilder*, swift::AbstractFunctionDecl*, swift::GenericTypeResolver&) + 107
12 swift                    0x000000010fc8b5f1 swift::TypeChecker::validateGenericFuncSignature(swift::AbstractFunctionDecl*) + 513
13 swift                    0x000000010fc713f9 (anonymous namespace)::DeclChecker::visitConstructorDecl(swift::ConstructorDecl*) + 1097
14 swift                    0x000000010fc614eb (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 251
15 swift                    0x000000010fc6f83b (anonymous namespace)::DeclChecker::visitClassDecl(swift::ClassDecl*) + 315
16 swift                    0x000000010fc614db (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 235
17 swift                    0x000000010fc613e4 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 100
18 swift                    0x000000010fcdbf84 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1524
19 swift                    0x000000010f8db089 swift::CompilerInstance::performSema() + 3897
20 swift                    0x000000010ee9451c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4380
21 swift                    0x000000010ee51e00 main + 3312
22 libdyld.dylib            0x00007fffa24ee255 start + 1
23 libdyld.dylib            0x000000000000003e start + 1571888618
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2017-03-08-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/Michael/Desktop/SegFault11/SegFault11/SegFault11.swift /Users/Michael/Desktop/SegFault11/SegFault11/ViewController.swift /Users/Michael/Desktop/SegFault11/SegFault11/AppDelegate.swift -target x86_64-apple-ios10.3 -enable-objc-interop -sdk /Users/Michael/Downloads/Xcode-beta 2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -I /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Products/Debug-iphonesimulator -F /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/Michael/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/SegFault11-generated-files.hmap -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/SegFault11-own-target-headers.hmap -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/SegFault11-all-target-headers.hmap -Xcc -iquote -Xcc /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/SegFault11-project-headers.hmap -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/DerivedSources/x86_64 -Xcc -I/Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/Michael/Desktop/SegFault11 -emit-module-doc-path /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11~partial.swiftdoc -serialize-diagnostics-path /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11.dia -Onone -module-name SegFault11 -emit-module-path /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11~partial.swiftmodule -emit-dependencies-path /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11.d -emit-reference-dependencies-path /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11.swiftdeps -o /Users/Michael/Library/Developer/Xcode/DerivedData/SegFault11-hkkupaxdvvekoialydwpgjtxyxyr/Build/Intermediates/SegFault11.build/Debug-iphonesimulator/SegFault11.build/Objects-normal/x86_64/SegFault11.o 
1.  While type-checking 'ObjectCollection' at /Users/Michael/Desktop/SegFault11/SegFault11/SegFault11.swift:18:7
2.  While type-checking 'init' at /Users/Michael/Desktop/SegFault11/SegFault11/SegFault11.swift:22:5
@belkadan
Copy link
Contributor

@belkadan belkadan commented Mar 10, 2017

Yikes. @slavapestov, @DougGregor, this is an area you've been actively working on.

@belkadan
Copy link
Contributor

@belkadan belkadan commented Mar 10, 2017

@swift-ci create

@DougGregor
Copy link
Member

@DougGregor DougGregor commented Mar 10, 2017

`GenericSignatureBuilder` is in the backtrace, so this crash is on master.

@DougGregor
Copy link
Member

@DougGregor DougGregor commented Mar 10, 2017

Hah, I ran across and fixed this issue last night.

@DougGregor
Copy link
Member

@DougGregor DougGregor commented Mar 10, 2017

@belkadan
Copy link
Contributor

@belkadan belkadan commented Mar 10, 2017

The originator says it's also failing in the 3.1 branch.

@DougGregor
Copy link
Member

@DougGregor DougGregor commented Mar 10, 2017

The example project builds with Xcode 8.3 beta 4, I broke this recently on master, and the stack trace is showing a type (`GenericSignatureBuilder`) that didn't exist on the 3.1 branch.

I'll check the latest 3.1 snapshot to see if there's something fishy there.

@DougGregor
Copy link
Member

@DougGregor DougGregor commented Mar 10, 2017

The 3.1 snapshot from March 8th builds cleanly, too. I think the submitter grabbed the snapshot from master, which had this bug (and which I subsequently fixed).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants