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-7457] Segfault when overriding function with multiple overloads #50000

Closed
0xpablo opened this issue Apr 17, 2018 · 4 comments
Closed

[SR-7457] Segfault when overriding function with multiple overloads #50000

0xpablo opened this issue Apr 17, 2018 · 4 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

Comments

@0xpablo
Copy link

0xpablo commented Apr 17, 2018

Previous ID SR-7457
Radar rdar://problem/39492060
Original Reporter @0xpablo
Type Bug
Status Closed
Resolution Done
Environment

macOS Xcode 9.3 (Swift 4.1 - swiftlang-902.0.48 clang-902.0.39.1)

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

md5: cc146bb190c93b6b3cbedef7ab7475e7

Issue Description:

Hello, I ran into a segfault when overriding in a child class a function with several overloads.

Here is a test case that reproduces the issue:

protocol Proto { }

class Class {
    func foo<A>(callback: (A) -> Void) where A: Proto {
    }

    func foo<A, B>(callback: (A, B) -> Void) where A: Proto, B: Proto {
    }
}

class Child: Class {
    override func foo<A>(callback: (A) -> Void) where A : Proto {
    }
}

This is happening under Xcode 9.3 (Swift 4.1) I also tried with the latest development snapshot (swift-DEVELOPMENT-SNAPSHOT-2018-04-16-a-osx) and the problem is still there.

Here are the outputs, in case are useful:

Xcode 9.3

0  swift                    0x000000010bc58ffa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010bc583b6 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff78321f5a _sigtramp + 26
3  swift                    0x00000001096c3333 substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions) + 211
4  swift                    0x00000001096c1fb8 swift::TypeBase::replaceSelfParameterType(swift::Type) + 24
5  swift                    0x00000001096cafad swift::TypeBase::adjustSuperclassMemberDeclType(swift::ValueDecl const*, swift::ValueDecl const*, swift::Type) + 365
6  swift                    0x00000001092e1268 (anonymous namespace)::DeclChecker::checkOverrides(swift::TypeChecker&, swift::ValueDecl*) + 2904
7  swift                    0x00000001092f022a (anonymous namespace)::DeclChecker::visitFuncDecl(swift::FuncDecl*) + 6394
8  swift                    0x00000001092e519c (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 3788
9  swift                    0x00000001092ed86b (anonymous namespace)::DeclChecker::visitClassDecl(swift::ClassDecl*) + 699
10 swift                    0x00000001092e465e (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 910
11 swift                    0x0000000109381952 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int) + 1714
12 swift                    0x0000000109003d67 swift::CompilerInstance::performSema() + 6407
13 swift                    0x00000001082b0054 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1892
14 swift                    0x00000001082ade64 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7908
15 swift                    0x00000001082628b5 main + 18917
16 libdyld.dylib            0x00007fff78013015 start + 1
17 libdyld.dylib            0x0000000000000046 start + 2281623602

1.  While type-checking 'Child' at file.swift:21:1
2.  While type-checking 'foo(callback:)' at file.swift:22:11

swift-DEVELOPMENT-SNAPSHOT-2018-04-16-a-osx

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.
0  swift                    0x00000001079bcbb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x00000001079bd2c6 SignalHandler(int) + 694
2  libsystem_platform.dylib 0x00007fff78321f5a _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 2278416576
4  libsystem_c.dylib        0x00007fff780bf1ae abort + 127
5  libsystem_c.dylib        0x00007fff780871ac basename_r + 0
6  swift                    0x00000001054664aa swift::TypeBase::replaceSelfParameterType(swift::Type) + 330
7  swift                    0x0000000105470780 swift::TypeBase::adjustSuperclassMemberDeclType(swift::ValueDecl const*, swift::ValueDecl const*, swift::Type) + 304
8  swift                    0x0000000105098b89 (anonymous namespace)::DeclChecker::checkOverrides(swift::TypeChecker&, swift::ValueDecl*) + 1833
9  swift                    0x000000010509fc91 swift::TypeChecker::validateDecl(swift::ValueDecl*) + 9905
10 swift                    0x00000001050b1b99 (anonymous namespace)::DeclChecker::visitFuncDecl(swift::FuncDecl*) + 41
11 swift                    0x000000010509a75e (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 190
12 swift                    0x00000001050afecb (anonymous namespace)::DeclChecker::visitClassDecl(swift::ClassDecl*) + 283
13 swift                    0x000000010509a92e (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 654
14 swift                    0x000000010509a696 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 38
15 swift                    0x00000001051369f8 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int) + 1704
16 swift                    0x0000000104d6e087 swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 855
17 swift                    0x0000000104d6d8f8 swift::CompilerInstance::performSema() + 472
18 swift                    0x00000001041fd5d0 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1904
19 swift                    0x00000001041fbe4e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3310
20 swift                    0x00000001041ba203 main + 2051
21 libdyld.dylib            0x00007fff78013015 start + 1

1.  While type-checking 'Child' at file.swift:21:1
2.  While type-checking 'foo(callback:)' at file.swift:22:11
3.  While validating 'foo(callback:)' at file.swift:22:11
@belkadan
Copy link
Contributor

Thanks, Pablo!

@swift-ci create

@belkadan
Copy link
Contributor

This got fixed in Swift 4.2.

#16068

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Jul 26, 2018

@0xpablo, Could you verify if the problem is fixed and if so move the JIRA to "Closed"?
Thanks!
Anna

@0xpablo
Copy link
Author

0xpablo commented Jul 26, 2018

I verified it and it's working in Swift 4.2. Thank you very much!

@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

3 participants