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-11413] Failed to emit SIL function using assoctype within extension where constrained by equal operator with Self #53814

Closed
kateinoigakukun opened this issue Sep 4, 2019 · 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

Comments

@kateinoigakukun
Copy link
Member

Previous ID SR-11413
Radar None
Original Reporter @kateinoigakukun
Type Bug
Status Resolved
Resolution Duplicate
Environment

Apple Swift version 5.1 (swiftlang-1100.0.212.5 clang-1100.0.28.2)
Target: x86_64-apple-darwin18.7.0

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

md5: 42022088ef58c7662afbec33fe72bd70

duplicates:

  • SR-10551 Segfault 11 when compiling with certain protocol extensions & associatedtypes

Issue Description:

protocol P {
    associatedtype X
}

extension P where Self == S {
    func f(x: X) {}
}

struct S: P {
    typealias X = Int
}
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret _tmp.swift -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -module-name _tmp
1.  While emitting SIL for 'f(x:)' (at _tmp.swift:6:5)
0  swift                    0x000000010c242c83 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010c242456 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff60628b5d _sigtramp + 29
3  swift                    0x0000000108e37947 substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolDecl*)>, swift::SubstOptions) + 295
4  swift                    0x000000010877d1e0 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>) + 1568
5  swift                    0x000000010877c7ac 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>) + 908
6  swift                    0x00000001087801f5 getUncachedSILFunctionTypeForConstant(swift::SILModule&, swift::SILDeclRef, swift::CanTypeWrapper<swift::AnyFunctionType>) + 469
7  swift                    0x00000001087820d6 swift::Lowering::TypeConverter::getConstantInfo(swift::SILDeclRef) + 934
8  swift                    0x00000001087ab06b swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter) + 91
9  swift                    0x0000000108282b4b swift::Lowering::SILGenModule::getFunction(swift::SILDeclRef, swift::ForDefinition_t) + 459
10 swift                    0x0000000108284176 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 790
11 swift                    0x0000000108379e7c SILGenExtension::visitFuncDecl(swift::FuncDecl*) + 316
12 swift                    0x00000001083798b7 swift::Lowering::SILGenModule::visitExtensionDecl(swift::ExtensionDecl*) + 151
13 swift                    0x000000010828eab6 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 1238
14 swift                    0x0000000108290591 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*) + 1329
15 swift                    0x0000000107e95795 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 31349
16 swift                    0x0000000107e8a474 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6868
17 swift                    0x0000000107e18fb3 main + 1219
18 libdyld.dylib            0x00007fff6043d3d5 start + 1
19 libdyld.dylib            0x000000000000000a start + 2679909430
@belkadan
Copy link
Contributor

belkadan commented Sep 4, 2019

Possibly related to SR-11407? The compiler doesn't do too well with constraints that make a previously unknown type fully-constrained. In this case we could probably reject it completely and say "just write extension S", even though that has slightly different access control implications. cc @slavapestov

@slavapestov
Copy link
Member

I don't think it will be difficult to fix the crashes with this edge case, but yeah, it's better to just write "extension S" instead.

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

No branches or pull requests

4 participants