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-13365] Segmentation fault: 11 #55802

Open
swift-ci opened this issue Aug 7, 2020 · 2 comments
Open

[SR-13365] Segmentation fault: 11 #55802

swift-ci opened this issue Aug 7, 2020 · 2 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

@swift-ci
Copy link
Collaborator

swift-ci commented Aug 7, 2020

Previous ID SR-13365
Radar rdar://problem/67361238
Original Reporter linqingmo (JIRA User)
Type Bug
Environment

Xcode 11.6

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

md5: f1f7a384ca8e96740fe4ebe78da284eb

Issue Description:

extension Result: Decodable where Success: Decodable, Failure: Decodable {
    public init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        do {
            let success = try container.decode(Success.self)
            self = .success(success)
        } catch {
            let failure = try container.decode(Failure.self)
            self = .failure(failure)
        }
    }
}


struct Failure: Error, Decodable {
    let message: String
}


class Test<V: Decodable> {}


class Test2<V: Decodable>: Test<Result<V, Failure>> { // Error
}


protocol CustomDecodable: Decodable {
    init(fromCustom decoder: Decoder) throws
}


extension Result: CustomDecodable where Success: Decodable, Failure: Decodable {
    public init(fromCustom decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        do {
            let success = try container.decode(Success.self)
            self = .success(success)
        } catch {
            let failure = try container.decode(Failure.self)
            self = .failure(failure)
        }
    }
}


class TestC<V: CustomDecodable> {}


class Test3<V: CustomDecodable>: TestC<Result<V, Failure>> { // OK
}

error:

1.  Apple Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)
2.  While emitting IR for source file /Users/linqingmo/lolipop/TestDecodable/TestDecodable/main.swift
3.  While emitting class metadata for 'Test2' (at /Users/linqingmo/lolipop/TestDecodable/TestDecodable/main.swift:32:1)
4.  While emitting metadata for 'Test2' (at /Users/linqingmo/lolipop/TestDecodable/TestDecodable/main.swift:32:1)
0  swift                    0x000000010f0e64ea PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010f0e5cc0 SignalHandler(int) + 352
2  libsystem_platform.dylib 0x00007fff6bfd45fd _sigtramp + 29
3  swift                    0x000000010bf42650 llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<swift::ProtocolConformanceRef (swift::CanType, swift::Type, swift::ProtocolDecl*)>, swift::SubstOptions)::$_23>(long, swift::TypeBase*) + 0
4  swift                    0x000000010bebf1ef swift::GenericSignatureImpl::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*) + 31
5  swift                    0x000000010bdd8a65 swift::Mangle::ASTMangler::appendConcreteProtocolConformance(swift::ProtocolConformance const*) + 1925
6  swift                    0x000000010bdd5e17 swift::Mangle::ASTMangler::appendRetroactiveConformances(swift::SubstitutionMap, swift::ModuleDecl*) + 199
7  swift                    0x000000010bdd3ec6 swift::Mangle::ASTMangler::appendType(swift::Type, swift::ValueDecl const*) + 8774
8  swift                    0x000000010b05fcbf swift::irgen::IRGenMangler::mangleTypeForReflection(swift::irgen::IRGenModule&, swift::Type) + 255
9  swift                    0x000000010b003cd6 getTypeRefImpl(swift::irgen::IRGenModule&, swift::CanType, swift::CanGenericSignature, swift::irgen::MangledTypeRefRole) + 1430
10 swift                    0x000000010afb9fc4 (anonymous namespace)::TypeContextDescriptorBuilderBase<(anonymous namespace)::ClassContextDescriptorBuilder, swift::ClassDecl>::emit() + 3172
11 swift                    0x000000010afd5186 swift::irgen::emitClassMetadata(swift::irgen::IRGenModule&, swift::ClassDecl*, swift::irgen::ClassLayout const&, swift::irgen::ClassLayout const&) + 22246
12 swift                    0x000000010af01aaa swift::irgen::IRGenModule::emitClassDecl(swift::ClassDecl*) + 346
13 swift                    0x000000010af1177b swift::irgen::IRGenModule::emitSourceFile(swift::SourceFile&) + 123
14 swift                    0x000000010b04b65e 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**) + 1118
15 swift                    0x000000010ae42a5f performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, bool, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, bool, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 4255
16 swift                    0x000000010ae37eba swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 48426
17 swift                    0x000000010adafb73 main + 1283
18 libdyld.dylib            0x00007fff6bddbcc9 start + 1
19 libdyld.dylib            0x000000000000004a start + 2485273474
error: Segmentation fault: 11
@theblixguy
Copy link
Collaborator

You seem to have created a TensorFlow bug report, rather than a Swift bug report. Anyway, here's a simplified reproducer:

extension Result: Decodable where Success: Decodable, Failure: Decodable {
  public init(from decoder: Decoder) throws {
    fatalError()
  }
}

struct Failure: Error, Decodable {}

class Base<T: Decodable> {}
class Derived<T: Decodable>: Base<Result<T, Failure>> {}

@typesanitizer
Copy link

@swift-ci create

@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
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