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-9583] Multifile Compiler Crash: "No interface type was set" #52030

Closed
nsalmoria opened this issue Dec 29, 2018 · 2 comments
Closed

[SR-9583] Multifile Compiler Crash: "No interface type was set" #52030

nsalmoria opened this issue Dec 29, 2018 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software multiple files Flag: An issue whose reproduction requires multiple files

Comments

@nsalmoria
Copy link
Contributor

Previous ID SR-9583
Radar rdar://problem/47097468
Original Reporter @nsalmoria
Type Bug
Status Resolved
Resolution Done
Environment

macOS 10.14.2, Xcode 10.1 both with default toolchain and with development snapshot 2018-12-28.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, MultiFile
Assignee @slavapestov
Priority Medium

md5: f9022464780e1790d83845e2b64f7289

Issue Description:

This crash happens only when the source is split over two files.

The crash only happens when compiling the Debug build. Release compiles fine.

In main.swift:

protocol P {
    associatedtype A
    typealias T = S1<Self>
}

struct S1<G: P>: Sequence, IteratorProtocol {
    mutating func next() -> G.A? {
        return nil
    }
}

func f(_: LazyFilterSequence<S3.T>) { }

In a separate file:

struct S2 {
    let v: Int
}

struct S3: P {
    typealias A = S2
}

With Development Snapshot 2018-12-28, this is the crash log:

Assertion failed: (hasInterfaceType() && "No interface type was set"), function getInterfaceType, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/AST/Decl.cpp, line 2390.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2018-12-28-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/nicolasalmoria/Documents/BugReportCompilerCrash6/NoInterface/main.swift /Users/nicolasalmoria/Documents/BugReportCompilerCrash6/NoInterface/file2.swift -emit-module-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/Objects-normal/x86_64/main~partial.swiftmodule -emit-module-doc-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/Objects-normal/x86_64/main~partial.swiftdoc -serialize-diagnostics-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/Objects-normal/x86_64/main.dia -emit-dependencies-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/Objects-normal/x86_64/main.d -emit-reference-dependencies-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/Objects-normal/x86_64/main.swiftdeps -target x86_64-apple-macosx10.14 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Products/Debug -F /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Products/Debug -enable-testing -g -module-cache-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/NoInterface-generated-files.hmap -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/NoInterface-own-target-headers.hmap -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/NoInterface-all-target-headers.hmap -Xcc -iquote -Xcc /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/NoInterface-project-headers.hmap -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Products/Debug/include -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/DerivedSources/x86_64 -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/nicolasalmoria/Documents/BugReportCompilerCrash6 -module-name NoInterface -o /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Build/Intermediates.noindex/NoInterface.build/Debug/NoInterface.build/Objects-normal/x86_64/main.o -index-store-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/NoInterface-cysnzeaanjyvoqeihujqumovxcnt/Index/DataStore -index-system-modules 
1.  While running pass #&#8203;11 SILModuleTransform "LoadableByAddress".
2.  While converting type 'LazyFilterSequence<S1<S3>>'
0  swift                    0x0000000104f27d98 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000104f27015 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000104f283a2 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff768b7b3d _sigtramp + 29
4  swift                    0x00000001026bbdf5 swift::SelfBoundsFromWhereClauseRequest::evaluate(swift::Evaluator&, llvm::PointerUnion<swift::TypeDecl*, swift::ExtensionDecl*>) const + 117
5  libsystem_c.dylib        0x00007fff767751c9 abort + 127
6  libsystem_c.dylib        0x00007fff7673d868 basename_r + 0
7  swift                    0x0000000102623022 swift::ValueDecl::getInterfaceType() const + 50
8  swift                    0x00000001026efdea swift::TypeBase::getTypeOfMember(swift::ModuleDecl*, swift::ValueDecl const*, swift::Type) + 42
9  swift                    0x00000001021c761c (anonymous namespace)::LowerType::visitAnyStructType(swift::CanType, swift::StructDecl*) + 284
10 swift                    0x00000001021be74a swift::Lowering::TypeConverter::getTypeLoweringForUncachedLoweredType(swift::Lowering::TypeConverter::TypeKey) + 186
11 swift                    0x00000001021bda0b swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type) + 907
12 swift                    0x000000010211aa50 (anonymous namespace)::DestructureInputs::visit(swift::ValueOwnership, bool, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILFunctionTypeRepresentation) + 208
13 swift                    0x00000001021190d6 getSILFunctionType(swift::SILModule&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::AnyFunctionType::ExtInfo, (anonymous namespace)::Conventions const&, swift::ForeignInfo const&, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, llvm::Optional<swift::ProtocolConformanceRef>) + 1974
14 swift                    0x00000001021138c3 getNativeSILFunctionType(swift::SILModule&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::AnyFunctionType::ExtInfo, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, llvm::Optional<swift::ProtocolConformanceRef>) + 1219
15 swift                    0x00000001021133aa swift::getNativeSILFunctionType(swift::SILModule&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, llvm::Optional<swift::ProtocolConformanceRef>) + 314
16 swift                    0x00000001021bde6c swift::Lowering::TypeConverter::getLoweredRValueType(swift::Lowering::AbstractionPattern, swift::CanType) + 956
17 swift                    0x00000001021bd80b swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type) + 395
18 swift                    0x000000010218bcf1 swift::SILType::getFieldType(swift::VarDecl*, swift::SILModule&) const + 177
19 swift                    0x000000010147c719 swift::irgen::TypeConverter::convertStructType(swift::TypeBase*, swift::CanType, swift::StructDecl*) + 4297
20 swift                    0x0000000101496f49 swift::irgen::TypeConverter::convertAnyNominalType(swift::CanType, swift::NominalTypeDecl*) + 537
21 swift                    0x00000001014962d6 swift::irgen::TypeConverter::convertType(swift::CanType) + 150
22 swift                    0x0000000101495d8e swift::irgen::TypeConverter::getTypeEntry(swift::CanType) + 638
23 swift                    0x00000001014956f0 swift::irgen::IRGenModule::getTypeInfoForLowered(swift::CanType) + 16
24 swift                    0x00000001014ee640 isLargeLoadableType(swift::GenericEnvironment*, swift::SILType, swift::irgen::IRGenModule&) + 224
25 swift                    0x00000001014ed79d LargeSILTypeMapper::getNewSILType(swift::GenericEnvironment*, swift::SILType, swift::irgen::IRGenModule&) + 349
26 swift                    0x00000001014f3813 (anonymous namespace)::LoadableStorageAllocation::allocateLoadableStorage() + 1091
27 swift                    0x00000001014ef8d1 (anonymous namespace)::LoadableByAddress::run() + 1089
28 swift                    0x0000000101e7fb8b swift::SILPassManager::runModulePass(unsigned int) + 1019
29 swift                    0x0000000101e805f4 swift::SILPassManager::execute() + 692
30 swift                    0x00000001014aa72b swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 187
31 swift                    0x00000001014aa182 runIRGenPreparePasses(swift::SILModule&, swift::irgen::IRGenModule&) + 162
32 swift                    0x00000001014a86c3 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 995
33 swift                    0x00000001014a8c96 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::GlobalVariable**) + 86
34 swift                    0x000000010135a8d3 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13171
35 swift                    0x00000001013564f2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2978
36 swift                    0x000000010130845e main + 686
37 libdyld.dylib            0x00007fff766cced9 start + 1
38 libdyld.dylib            0x0000000000000043 start + 2308125035
error: Abort trap: 6
@slavapestov
Copy link
Member

We’re not checking the conformance S3 : P early enough, so the members of S2 never get type checked since we don’t drain the DeclsToFinalize list again.

Making the type checker live forever papers over this issue; we would have crashed earlier if that wasn’t the case. What we really need to do is get rid of FinalizeDecls and so on entirely, and switch to a ‘pull’ model.

@slavapestov
Copy link
Member

#26159

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software multiple files Flag: An issue whose reproduction requires multiple files
Projects
None yet
Development

No branches or pull requests

3 participants