swiftlang / swift

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

[SR-10728] Conditional Conformance Compiler Crash #53125

Closed swift-ci closed 5 years ago

swift-ci commented 5 years ago
Previous ID SR-10728
Radar rdar://problem/50987089
Original Reporter mansbernhardt (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment Xcode 10.2.1 snapshot 5.1 (May 9, 2019) snapshot (May 19, 2019)
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, 5.1Regression, CompilerCrash, TypeChecker | |Assignee | mansbernhardt (JIRA) | |Priority | Medium | md5: 77e9b40491013eccfa18caaa72bd1d97

is duplicated by:

Issue Description:

Code that compiles in Xcode 5.0 does not compile in latest snapshot 5.1 (May 9, 2019) nor latest snapshot (May 19, 2019).

The code that does not compile can be find at:

https://github.com/iZettle/Form/blob/c31c4e2ebed4468f5d5d81915cfcd0926a72f3b7/Form/Reusable.swift#L107

```

extension Either: Reusable where Left: Reusable, Right: Reusable, Left.ReuseType: ViewRepresentable, Right.ReuseType: ViewRepresentable {

```

The crash seems to be an assertion failure:

```

Assertion failed: (Val && "isa\<> used on a null pointer"), function doit, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/llvm/include/llvm/Support/Casting.h, line 106.

```

with the callstack:

```

1. Apple Swift version 5.1-dev (LLVM 082dec2e22, Swift 5ca038368d)

2. While type-checking protocol conformance to 'Reusable' (at /Users/manber/dev/playgrounds/Binder/Pods/FormFramework/Form/Reusable.swift:14:8) for type 'Either\<Left, Right>'

0 swift 0x000000010cdd4f35 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37

1 swift 0x000000010cdd41f5 llvm::sys::RunSignalHandlers() + 85

2 swift 0x000000010cdd5518 SignalHandler(int) + 264

3 libsystem_platform.dylib 0x00007fff68f32b5d _sigtramp + 29

4 libsystem_platform.dylib 0x000000011a2c4938 _sigtramp + 2973310456

5 libsystem_c.dylib 0x00007fff68df26a6 abort + 127

6 libsystem_c.dylib 0x00007fff68dbb20d basename_r + 0

7 swift 0x0000000109c40a07 swift::constraints::simplifyLocator(swift::Expr*&, llvm::ArrayRef\<swift::constraints::ConstraintLocator::PathElement>&, swift::SourceRange&) + 807

8 swift 0x0000000109d5eb45 swift::constraints::ConstraintLocatorBuilder::trySimplifyToExpr() const + 85

9 swift 0x0000000109c83839 swift::constraints::ConstraintSystem::matchFunctionTypes(swift::FunctionType*, swift::FunctionType*, swift::constraints::ConstraintKind, swift::OptionSet\<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 1257

10 swift 0x0000000109c80711 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet\<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 2721

11 swift 0x0000000109c7fa79 swift::constraints::ConstraintSystem::matchTupleTypes(swift::TupleType*, swift::TupleType*, swift::constraints::ConstraintKind, swift::OptionSet\<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 329

12 swift 0x0000000109c8084f swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet\<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 3039

13 swift 0x0000000109c94807 swift::constraints::ConstraintSystem::addConstraintImpl(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) + 103

14 swift 0x0000000109c7f8af swift::constraints::ConstraintSystem::addConstraint(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) + 63

15 swift 0x0000000109ddc473 llvm::Optional\<swift::RequirementMatch> llvm::function_ref\<llvm::Optional\<swift::RequirementMatch> (swift::Type, swift::Type)>::callbackfn\<swift::matchWitness(swift::TypeChecker&, llvm::DenseMap\<std::\1::pair\<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment, llvm::DenseMapInfo\<std::1::pair\<swift::GenericSignature const*, swift::ClassDecl const*> >, llvm::detail::DenseMapPair\<std::_1::pair\<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::ProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*)::$_1>(long, swift::Type, swift::Type) + 115

16 swift 0x0000000109dc53f7 swift::matchWitness(swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*, llvm::functionref\<std::\_1::tuple\<llvm::Optional\<swift::RequirementMatch>, swift::Type, swift::Type> ()>, llvm::function_ref\<llvm::Optional\<swift::RequirementMatch> (swift::Type, swift::Type)>, llvm::function_ref\<swift::RequirementMatch (bool, llvm::ArrayRef\<swift::OptionalAdjustment>)>) + 5383

17 swift 0x0000000109dc6427 swift::matchWitness(swift::TypeChecker&, llvm::DenseMap\<std::_1::pair\<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment, llvm::DenseMapInfo\<std::1::pair\<swift::GenericSignature const*, swift::ClassDecl const*> >, llvm::detail::DenseMapPair\<std::_1::pair\<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::ProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*) + 1015

18 swift 0x0000000109dc6d04 swift::WitnessChecker::findBestWitness(swift::ValueDecl*, bool*, swift::NormalProtocolConformance*, llvm::SmallVectorImpl\<swift::RequirementMatch>&, unsigned int&, unsigned int&, bool&) + 564

19 swift 0x0000000109dce85d swift::ConformanceChecker::resolveWitnessViaLookup(swift::ValueDecl*) + 637

20 swift 0x0000000109dd0a8d swift::ConformanceChecker::resolveValueWitnesses() + 349

21 swift 0x0000000109dcb252 swift::ConformanceChecker::checkConformance(swift::MissingWitnessDiagnosisKind) + 402

22 swift 0x0000000109dc9fba swift::MultiConformanceChecker::checkIndividualConformance(swift::NormalProtocolConformance*, bool) + 8026

23 swift 0x0000000109dc7e92 swift::MultiConformanceChecker::checkAllConformances() + 114

24 swift 0x0000000109dd30b3 swift::TypeChecker::checkConformancesInContext(swift::DeclContext*, swift::IterableDeclContext*) + 4387

25 swift 0x0000000109e22c2b typeCheckFunctionsAndExternalDecls(swift::SourceFile&, swift::TypeChecker&) + 171

26 swift 0x0000000109e2375b swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet\<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1019

27 swift 0x0000000109568322 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 530

28 swift 0x0000000109567a57 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 615

29 swift 0x00000001093318df performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef\<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1615

30 swift 0x0000000109330232 swift::performFrontend(llvm::ArrayRef\<char const*>, char const*, void*, swift::FrontendObserver*) + 2978

31 swift 0x00000001092d65a9 main + 729

32 libdyld.dylib 0x00007fff68d4d3d5 start + 1

33 libdyld.dylib 0x00000000000000ba start + 2536189158

error: Abort trap: 6

```

xedin commented 5 years ago

Hi mansbernhardt (JIRA User) could you please help me to figure out how to build the project property to reproduce this problem? I tried using Carthage to install FlowFramework but it uses default Xcode toolchain?...

swift-ci commented 5 years ago

Comment by Måns Bernhardt (JIRA)

@xedin I just tested using Xcode 11 beta 2 and Swift 5.1 and it seems to compile and run again. Here is what I did to test it. Select the latest beta 2 for command line (xcode-select). Clone the Form repo (https://github.com/iZettle/Form) and run `carthage update` from the root of the repo to fetch and build the dependencies (using the 5.1 compiler). Then just open the project in Xcode 11 beta 2 and build the project.

xedin commented 5 years ago

Fixed by https://github.com/apple/swift/pull/26092. Please verify using the next available nightly snapshot of master or 5.1 branch.

bc7072e8-7d37-4a38-8fee-cab463d443b7 commented 5 years ago

mansbernhardt (JIRA User), Could you verify if the problem is fixed and if so move the JIRA to "Closed"?

Thanks!
Anna

swift-ci commented 5 years ago

Comment by Måns Bernhardt (JIRA)

@Anna I don’t seem to have the privileges to close the issue, but as I mentioned in the comments the issue has been verified as fixed, so you’re welcome to close it.

swift-ci commented 5 years ago

Comment by Måns Bernhardt (JIRA)

See also https://github.com/iZettle/Form/issues/114

bc7072e8-7d37-4a38-8fee-cab463d443b7 commented 5 years ago

Thanks!