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-14118] Inheriting from a type whose init is generically overloaded crashes the compiler #56499

Closed
swift-ci opened this issue Jan 28, 2021 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-14118
Radar rdar://problem/73764827
Original Reporter lhunath (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 5b0014e02c8f789ec7a08a9c1acc13e4

Issue Description:

In the following code, B inherits from A, while A's init is overloaded to handle the case where the generic E type parameter is Identifiable.

class A<E: Hashable> {
    public init() {
    }
    public init() where E: Identifiable {
    }
}
class B<E : Hashable>: A<E> {
}

This results in swiftc crashing:

$ swiftc -v test.swift
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Target: x86_64-apple-darwin20.2.0
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file test.swift -target x86_64-apple-darwin20.2.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -color-diagnostics -target-sdk-version 11.1 -module-name test -o /var/folders/j0/j_bmd3qx5w9ccnrkxdcdsptc0000gn/T/test-5fb6af.o
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file test.swift -target x86_64-apple-darwin20.2.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -color-diagnostics -target-sdk-version 11.1 -module-name test -o /var/folders/j0/j_bmd3qx5w9ccnrkxdcdsptc0000gn/T/test-5fb6af.o
1.  Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
2.  While evaluating request SILGenSourceFileRequest(SIL Generation for file "test.swift")
0  swift                    0x0000000113bcf615 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x0000000113bce615 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000113bcfbcf SignalHandler(int) + 111
3  libsystem_platform.dylib 0x00007fff20365d7d _sigtramp + 29
4  libsystem_platform.dylib 0x00007ffee0569500 _sigtramp + 18446744072637921184
5  swift                    0x000000011032dfad getFunctionInterfaceTypeWithCaptures(swift::Lowering::TypeConverter&, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILDeclRef) + 557
6  swift                    0x00000001102b37d6 swift::Lowering::TypeConverter::getConstantInfo(swift::TypeExpansionContext, swift::SILDeclRef) + 70
7  swift                    0x00000001102abcf1 swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, llvm::function_ref<swift::SILFunction* (swift::SILLocation, swift::SILDeclRef)>, swift::ProfileCounter) + 145
8  swift                    0x000000010fbb8c93 swift::Lowering::SILGenModule::getFunction(swift::SILDeclRef, swift::ForDefinition_t) + 467
9  swift                    0x000000010fbbb040 swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 2112
10 swift                    0x000000010fcd03c7 swift::ASTVisitor<(anonymous namespace)::SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 231
11 swift                    0x000000010fccb7ab (anonymous namespace)::SILGenType::emitType() + 203
12 swift                    0x000000010fbc4e12 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 82
13 swift                    0x000000010fbc3139 (anonymous namespace)::SILGenModuleRAII::emitSourceFile(swift::SourceFile*) + 1417
14 swift                    0x000000010fbc2af9 swift::SILGenSourceFileRequest::evaluate(swift::Evaluator&, swift::SILGenDescriptor) const + 137
15 swift                    0x000000010fcbd9c1 swift::SimpleRequest<swift::SILGenSourceFileRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::SILGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::SILGenSourceFileRequest const&, swift::Evaluator&) + 33
16 swift                    0x000000010fbc992c llvm::Expected<swift::SILGenSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::SILGenSourceFileRequest>(swift::SILGenSourceFileRequest const&) + 972
17 swift                    0x000000010fbc498d swift::performSILGeneration(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 173
18 swift                    0x000000010f732cae swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 20462
19 swift                    0x000000010f6b3c27 main + 1255
20 libdyld.dylib            0x00007fff2033c621 start + 1
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)
@typesanitizer
Copy link

@swift-ci create

@slavapestov
Copy link
Member

#35728

@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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants