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-10532] Assertion failed: (conforms != equivClass->conformsTo.end()) #52932

Closed
SusanDoggie opened this issue Apr 22, 2019 · 4 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software IRGen LLVM IR generation

Comments

@SusanDoggie
Copy link
Contributor

Previous ID SR-10532
Radar rdar://problem/50169558
Original Reporter @SusanDoggie
Type Bug
Status Resolved
Resolution Done
Environment

Swift 5

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

md5: 5b1ae800fe04f78f4be7ad25bcc37128

Issue Description:

The following code shouldn't have any error but swift compiler get it wrong.

public protocol ScalarProtocol: ScalarMultiplicative where Self == Scalar {
    
}

public protocol ScalarMultiplicative {
    
    associatedtype Scalar : ScalarProtocol
    
}

public protocol MapReduceArithmetic : ScalarMultiplicative, Collection where Element : ScalarMultiplicative, Scalar == Element.Scalar {
    
}

public protocol Tensor : MapReduceArithmetic where Scalar : BinaryFloatingPoint, Element == Scalar {
    
    var magnitude: Scalar { get set }
}

extension Tensor {
    
    public var magnitude: Scalar {
        return self.reduce(0) { $0 + $1 * $1 }.squareRoot()
    }
}
@belkadan
Copy link
Contributor

It actually crashes for me on master:

Assertion failed: (conforms != equivClass->conformsTo.end()), function buildConformanceAccessPath, file /Volumes/Data/swift-public/swift/lib/AST/GenericSignature.cpp, line 924.
Stack dump:
0.  Program arguments: /Volumes/Data/swift-public/build/ninja/swift-macosx-x86_64/bin/swift -frontend -c -primary-file - -target x86_64-apple-darwin18.6.0 -enable-objc-interop -sdk /Volumes/Data/Applications/Xcode10.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name main -o /var/folders/_d/dmrgv26d3bs6lkrks9z825_w0000gn/T/--f83a70.o 
1.  While emitting IR SIL function "@$s4main6TensorPAAE9magnitude7ElementQzvg".
 for getter for magnitude (at <stdin>:22:16)
0  swift                    0x000000010aa05425 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010aa046e5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010aa05a08 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff60b19b5d _sigtramp + 29
4  libsystem_platform.dylib 0x00007fc9b18ff188 _sigtramp + 1356748360
5  libsystem_c.dylib        0x00007fff609d36a6 abort + 127
6  libsystem_c.dylib        0x00007fff6099c20d basename_r + 0
7  swift                    0x0000000107d3044b swift::GenericSignature::buildConformanceAccessPath(llvm::SmallVectorImpl<std::__1::pair<swift::Type, swift::ProtocolDecl*> >&, llvm::ArrayRef<swift::Requirement>, void const*, swift::ProtocolDecl*, swift::Type, swift::ProtocolDecl*) + 1691
8  swift                    0x0000000107d30345 swift::GenericSignature::buildConformanceAccessPath(llvm::SmallVectorImpl<std::__1::pair<swift::Type, swift::ProtocolDecl*> >&, llvm::ArrayRef<swift::Requirement>, void const*, swift::ProtocolDecl*, swift::Type, swift::ProtocolDecl*) + 1429
9  swift                    0x0000000107d2ffc4 swift::GenericSignature::buildConformanceAccessPath(llvm::SmallVectorImpl<std::__1::pair<swift::Type, swift::ProtocolDecl*> >&, llvm::ArrayRef<swift::Requirement>, void const*, swift::ProtocolDecl*, swift::Type, swift::ProtocolDecl*) + 532
10 swift                    0x0000000107d2ffc4 swift::GenericSignature::buildConformanceAccessPath(llvm::SmallVectorImpl<std::__1::pair<swift::Type, swift::ProtocolDecl*> >&, llvm::ArrayRef<swift::Requirement>, void const*, swift::ProtocolDecl*, swift::Type, swift::ProtocolDecl*) + 532
11 swift                    0x0000000107d2ffc4 swift::GenericSignature::buildConformanceAccessPath(llvm::SmallVectorImpl<std::__1::pair<swift::Type, swift::ProtocolDecl*> >&, llvm::ArrayRef<swift::Requirement>, void const*, swift::ProtocolDecl*, swift::Type, swift::ProtocolDecl*) + 532
12 swift                    0x0000000107d2ffc4 swift::GenericSignature::buildConformanceAccessPath(llvm::SmallVectorImpl<std::__1::pair<swift::Type, swift::ProtocolDecl*> >&, llvm::ArrayRef<swift::Requirement>, void const*, swift::ProtocolDecl*, swift::Type, swift::ProtocolDecl*) + 532
13 swift                    0x0000000107d30c75 swift::GenericSignature::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*) + 725
14 swift                    0x0000000106feb1ce swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 126
15 swift                    0x0000000106feb05c swift::irgen::emitAssociatedTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::AssociatedType, swift::irgen::DynamicMetadataRequest) + 108
16 swift                    0x0000000106feadb6 swift::irgen::emitArchetypeTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::irgen::DynamicMetadataRequest) + 246
17 swift                    0x0000000107169217 swift::CanTypeVisitor<(anonymous namespace)::EmitTypeMetadataRef, swift::irgen::MetadataResponse, swift::irgen::DynamicMetadataRequest>::visit(swift::CanType, swift::irgen::DynamicMetadataRequest) + 215
18 swift                    0x0000000107167231 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType, swift::irgen::DynamicMetadataRequest) + 145
19 swift                    0x0000000107167796 swift::CanTypeVisitor<(anonymous namespace)::EmitTypeMetadataRefForLayout, llvm::Value*, swift::irgen::DynamicMetadataRequest>::visit(swift::CanType, swift::irgen::DynamicMetadataRequest) + 150
20 swift                    0x00000001071676af swift::irgen::IRGenFunction::emitTypeMetadataRefForLayout(swift::SILType, swift::irgen::DynamicMetadataRequest) + 111
21 swift                    0x00000001070a82c9 swift::irgen::IRGenFunction::emitValueWitnessTableRef(swift::SILType, swift::irgen::DynamicMetadataRequest, llvm::Value**) + 201
22 swift                    0x00000001070a81f0 swift::irgen::IRGenFunction::emitValueWitnessTableRef(swift::SILType, llvm::Value**) + 48
23 swift                    0x00000001070ba19f swift::irgen::IRGenFunction::emitDynamicAlloca(swift::SILType, llvm::Twine const&) + 63
24 swift                    0x0000000106feec4a swift::irgen::WitnessSizedTypeInfo<(anonymous namespace)::OpaqueArchetypeTypeInfo>::allocateStack(swift::irgen::IRGenFunction&, swift::SILType, llvm::Twine const&) const + 42
25 swift                    0x000000010713235f swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 29311
26 swift                    0x0000000107127763 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8131
27 swift                    0x00000001070312be swift::irgen::IRGenerator::emitGlobalTopLevel() + 734
28 swift                    0x0000000107101b9d 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**) + 1373
29 swift                    0x00000001071020e6 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::GlobalVariable**) + 86
30 swift                    0x0000000106f96097 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 14615
31 swift                    0x0000000106f91722 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2978
32 swift                    0x0000000106f384f8 main + 696
33 libdyld.dylib            0x00007fff6092e3d5 start + 1

@rjmccall, thoughts?

@rjmccall
Copy link
Contributor

Usually this kind of crash is a problem with the generic signature checking code, in this case probably because of the knot-tying in `ScalarProtocol`. @slavapestov,@DougGregor?

@SusanDoggie
Copy link
Contributor Author

As i known, the Swift 5.0 compiler assume Tensor.Self == Tensor.Scalar but it's not correct. This bugs has being long time ago.

If removing the constraint Scalar == Element.Scalar in protocol MapReduceArithmetic, it will work properly.

@slavapestov
Copy link
Contributor

#42113

@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 itself crash Bug: A crash, i.e., an abnormal termination of software IRGen LLVM IR generation
Projects
None yet
Development

No branches or pull requests

5 participants