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-6797] Swift 4.1 regression: compiler crash after converting code to Swift 4.1 (missing explicit conformance in requirement signature) #49346

Closed
NachoSoto opened this issue Jan 19, 2018 · 10 comments
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 regression swift 4.1

Comments

@NachoSoto
Copy link
Contributor

Previous ID SR-6797
Radar rdar://problem/36673825
Original Reporter @NachoSoto
Type Bug
Status Resolved
Resolution Done
Environment

Swift version 4.1-dev (LLVM ef53654946, Clang f7df1e5a04, Swift 831b78c)

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

md5: de697ecbcfaa1dcca17310523e9ff045

Issue Description:

I started converting RandomKit to Swift 4.1. I made one change, compiled again, and now the project crashes the compiler. You can clone the branch on that exact state from my fork or download it directly from here.

Stack trace:

0  swift                    0x000000010a095ab8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010a094a06 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x000000010a09607e SignalHandler(int) + 366
3  libsystem_platform.dylib 0x00007fff54770f5a _sigtramp + 26
4  swift                    0x00000001077dc68e swift::CanType swift::CanTypeVisitor<(anonymous namespace)::SILTypeSubstituter, swift::CanType>::visit<>(swift::CanType) + 94
5  swift                    0x0000000107d54582 swift::GenericFunctionType::substGenericArgs(swift::SubstitutionMap const&) + 306
6  swift                    0x0000000107d54435 swift::GenericFunctionType::substGenericArgs(llvm::ArrayRef<swift::Substitution>) + 53
7  swift                    0x00000001072d18f5 (anonymous namespace)::Callee::forDirect(swift::Lowering::SILGenFunction&, swift::SILDeclRef, llvm::ArrayRef<swift::Substitution>, swift::SILLocation) + 165
8  swift                    0x00000001072dd0c7 swift::ASTVisitor<(anonymous namespace)::SILGenApply, void, void, void, void, void, void>::visit(swift::Expr*) + 3383
9  swift                    0x00000001072dfece (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 3022
10 swift                    0x00000001072dfece (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 3022
11 swift                    0x00000001072cda95 prepareApplyExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 133
12 swift                    0x00000001072cd9e5 swift::Lowering::SILGenFunction::emitApplyExpr(swift::Expr*, swift::Lowering::SGFContext) + 37
13 swift                    0x000000010732b7c4 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 84
14 swift                    0x0000000107326cf4 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 516
15 swift                    0x000000010738a814 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 596
16 swift                    0x000000010738a5b5 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
17 swift                    0x0000000107347949 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 425
18 swift                    0x00000001072c8916 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 262
19 swift                    0x00000001072c078c swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 604
20 swift                    0x0000000107396ce2 swift::ASTVisitor<SILGenExtension, void, void, void, void, void, void>::visit(swift::Decl*) + 290
21 swift                    0x0000000107394fdb SILGenExtension::emitExtension(swift::ExtensionDecl*) + 59
22 swift                    0x0000000107394f95 swift::Lowering::SILGenModule::visitExtensionDecl(swift::ExtensionDecl*) + 21
23 swift                    0x00000001072c54db swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 875
24 swift                    0x00000001072c61d5 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 437
25 swift                    0x00000001072c66ec swift::performSILGeneration(swift::ModuleDecl*, swift::SILOptions&, bool) + 28
26 swift                    0x0000000106c2a195 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 12709
27 swift                    0x0000000106c2602a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3210
28 swift                    0x0000000106be6da0 main + 3360
29 libdyld.dylib            0x00007fff544ef115 start + 1

I also see this in the build log:

Assertion failed: (hasConformanceInSignature(inProtocol->getRequirementSignature(), subjectType, conformingProto) && "missing explicit conformance in requirement signature"), function operator(), file /Users/buildnode/jenkins/workspace/oss-swift-4.1-package-osx/swift/lib/AST/GenericSignature.cpp, line 1037.
0  swift                    0x000000010f618ab8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010f617a06 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x000000010f61907e SignalHandler(int) + 366
3  libsystem_platform.dylib 0x00007fff54770f5a _sigtramp + 26
4  libdyld.dylib            0x00007fff544ef249 dyldGlobalLockRelease() + 0
5  libsystem_c.dylib        0x00007fff5459b312 abort + 127
6  libsystem_c.dylib        0x00007fff54563368 basename_r + 0
7  swift                    0x000000010d265509 std::__1::__function::__func<swift::GenericSignature::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*)::$_10, std::__1::allocator<swift::GenericSignature::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*)::$_10>, void (llvm::ArrayRef<swift::Requirement>, swift::GenericSignatureBuilder::RequirementSource const*, swift::ProtocolDecl*, swift::Type, swift::ProtocolDecl*)>::operator()(llvm::ArrayRef<swift::Requirement>&&, swift::GenericSignatureBuilder::RequirementSource const*&&, swift::ProtocolDecl*&&, swift::Type&&, swift::ProtocolDecl*&&) + 1513
8  swift                    0x000000010d263d41 swift::GenericSignature::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*) + 529
9  swift                    0x000000010d2cb04a swift::SubstitutionMap::lookupConformance(swift::CanType, swift::ProtocolDecl*) const + 234
10 swift                    0x000000010d2e0a25 llvm::Optional<swift::ProtocolConformanceRef> llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>::callback_fn<swift::LookUpConformanceInSubstitutionMap>(long, swift::CanType, swift::Type, swift::ProtocolType*) + 21
11 swift                    0x000000010d2bf73b swift::ProtocolConformanceRef::subst(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 379
12 swift                    0x000000010ca17a6e swift::SILCloner<swift::SILInliner>::visitWitnessMethodInst(swift::WitnessMethodInst*) + 174
13 swift                    0x000000010ca127d3 swift::SILCloner<swift::SILInliner>::visitSILBasicBlock(swift::SILBasicBlock*) + 83
14 swift                    0x000000010ca121e1 swift::SILInliner::inlineFunction(swift::FullApplySite, llvm::ArrayRef<swift::SILValue>) + 1025
15 swift                    0x000000010cab9d64 runOnFunctionRecursively(swift::SILFunction*, swift::FullApplySite, swift::SILOptions::LinkingMode, llvm::DenseSet<swift::SILFunction*, llvm::DenseMapInfo<swift::SILFunction*> >&, llvm::ImmutableSet<swift::SILFunction*, llvm::ImutContainerInfo<swift::SILFunction*> >::Factory&, llvm::ImmutableSet<swift::SILFunction*, llvm::ImutContainerInfo<swift::SILFunction*> >, swift::ClassHierarchyAnalysis*) + 3492
16 swift                    0x000000010cab8d17 (anonymous namespace)::MandatoryInlining::run() + 423
17 swift                    0x000000010ca3ab9b swift::SILPassManager::runModulePass(swift::SILModuleTransform*) + 1355
18 swift                    0x000000010ca3b721 swift::SILPassManager::runOneIteration() + 1041
19 swift                    0x000000010c2fdabb swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 187
20 swift                    0x000000010ca43b9c swift::runSILDiagnosticPasses(swift::SILModule&) + 172
21 swift                    0x000000010c1ac886 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 10390
22 swift                    0x000000010c1a902a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3210
23 swift                    0x000000010c169da0 main + 3360
24 libdyld.dylib            0x00007fff544ef115 start + 1

1.  While running pass #&#8203;901 SILModuleTransform "Mandatory Inlining of Transparent Functions".

I commented out a bunch of code (from the file that was crashing here), and got yet another crash from somewhere else:

Assertion failed: (hasConformanceInSignature(inProtocol->getRequirementSignature(), subjectType, conformingProto) && "missing explicit conformance in requirement signature"), function operator(), file /Users/buildnode/jenkins/workspace/oss-swift-4.1-package-osx/swift/lib/AST/GenericSignature.cpp, line 1037.
0  swift                    0x0000000109b92ab8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000109b91a06 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x0000000109b9307e SignalHandler(int) + 366
3  libsystem_platform.dylib 0x00007fff54770f5a _sigtramp + 26
4  libdyld.dylib            0x00007fff544ef249 dyldGlobalLockRelease() + 0
5  libsystem_c.dylib        0x00007fff5459b312 abort + 127
6  libsystem_c.dylib        0x00007fff54563368 basename_r + 0
7  swift                    0x00000001077df509 std::__1::__function::__func<swift::GenericSignature::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*)::$_10, std::__1::allocator<swift::GenericSignature::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*)::$_10>, void (llvm::ArrayRef<swift::Requirement>, swift::GenericSignatureBuilder::RequirementSource const*, swift::ProtocolDecl*, swift::Type, swift::ProtocolDecl*)>::operator()(llvm::ArrayRef<swift::Requirement>&&, swift::GenericSignatureBuilder::RequirementSource const*&&, swift::ProtocolDecl*&&, swift::Type&&, swift::ProtocolDecl*&&) + 1513
8  swift                    0x00000001077ddd41 swift::GenericSignature::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*) + 529
9  swift                    0x000000010784504a swift::SubstitutionMap::lookupConformance(swift::CanType, swift::ProtocolDecl*) const + 234
10 swift                    0x000000010785aa25 llvm::Optional<swift::ProtocolConformanceRef> llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>::callback_fn<swift::LookUpConformanceInSubstitutionMap>(long, swift::CanType, swift::Type, swift::ProtocolType*) + 21
11 swift                    0x000000010783973b swift::ProtocolConformanceRef::subst(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 379
12 swift                    0x0000000106f91a6e swift::SILCloner<swift::SILInliner>::visitWitnessMethodInst(swift::WitnessMethodInst*) + 174
13 swift                    0x0000000106f8c7d3 swift::SILCloner<swift::SILInliner>::visitSILBasicBlock(swift::SILBasicBlock*) + 83
14 swift                    0x0000000106f8c1e1 swift::SILInliner::inlineFunction(swift::FullApplySite, llvm::ArrayRef<swift::SILValue>) + 1025
15 swift                    0x0000000107033d64 runOnFunctionRecursively(swift::SILFunction*, swift::FullApplySite, swift::SILOptions::LinkingMode, llvm::DenseSet<swift::SILFunction*, llvm::DenseMapInfo<swift::SILFunction*> >&, llvm::ImmutableSet<swift::SILFunction*, llvm::ImutContainerInfo<swift::SILFunction*> >::Factory&, llvm::ImmutableSet<swift::SILFunction*, llvm::ImutContainerInfo<swift::SILFunction*> >, swift::ClassHierarchyAnalysis*) + 3492
16 swift                    0x0000000107032d17 (anonymous namespace)::MandatoryInlining::run() + 423
17 swift                    0x0000000106fb4b9b swift::SILPassManager::runModulePass(swift::SILModuleTransform*) + 1355
18 swift                    0x0000000106fb5721 swift::SILPassManager::runOneIteration() + 1041
19 swift                    0x0000000106877abb swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 187
20 swift                    0x0000000106fbdb9c swift::runSILDiagnosticPasses(swift::SILModule&) + 172
21 swift                    0x0000000106726886 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 10390
22 swift                    0x000000010672302a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3210
23 swift                    0x00000001066e3da0 main + 3360
24 libdyld.dylib            0x00007fff544ef115 start + 1
25 libdyld.dylib            0x00000000000000e0 start + 2880507852

So there's probably more than one issue compiling this project...
See also SR-6799 and SR-6800.

@jckarter
Copy link
Member

@swift-ci create

@NachoSoto
Copy link
Contributor Author

Note that the project currently has Swift 3.2 mode set, but it crashes the same way when changing it to Swift 4.0.

@NachoSoto
Copy link
Contributor Author

Found another compiler crash in a different project: https://bugs.swift.org/browse/SR-6799.

@NachoSoto
Copy link
Contributor Author

And another one: SR-6800

@DougGregor
Copy link
Member

#14091

@DougGregor
Copy link
Member

4.1 PR: #14102

@NachoSoto
Copy link
Contributor Author

Awesome! I can verify this when it gets released. Did you check that the project builds now? I got several different compile errors.

@DougGregor
Copy link
Member

I verified that the fork of RandomKit you pointed at builds with Swift master (using swiftpm to build RandomKit). There hasn't been a whole lot of divergence in this area between master and the 4.1 branch, so I expect the results will be the same there.

@NachoSoto
Copy link
Contributor Author

Awesome thanks! 🙂

@NachoSoto
Copy link
Contributor Author

Confirmed fixed, thanks!

@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 regression swift 4.1
Projects
None yet
Development

No branches or pull requests

4 participants