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-1813] Swift crashes emitting witness tables #44422

Closed
CodaFi opened this issue Jun 18, 2016 · 2 comments
Closed

[SR-1813] Swift crashes emitting witness tables #44422

CodaFi opened this issue Jun 18, 2016 · 2 comments
Assignees
Labels
compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software generics Feature: generic declarations and types IRGen LLVM IR generation

Comments

@CodaFi
Copy link
Member

CodaFi commented Jun 18, 2016

Previous ID SR-1813
Radar rdar://26873036
Original Reporter @CodaFi
Type New Feature
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels New Feature, CompilerCrash, IRGen
Assignee @CodaFi
Priority Medium

md5: 5f54a85eae8c2fcaabf20fac4091f5bb

relates to:

  • SR-1814 Crash on assignment of class array to protocol array

Issue Description:

Swift crashes on the input below (notes provided by Jun in the Swift labs)

// causes crash of swift-3.0-preview-1-SNAPSHOT-2016-05-31-a-osx and 2016-06-06
// /Library/Developer/Toolchains/swift-3.0-preview-1-SNAPSHOT-2016-05-31-a.xctoolchain/usr/bin/swift swift3-preview1-crash-example1.swift
// /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-06-06-a.xctoolchain/usr/bin/swift swift3-preview1-crash-example1.swift
// removing any of Equatable or type constraints will make it

protocol P1 {
    associatedtype A1: Equatable
}

class C1<T: Equatable> {
}

class C2<T: Equatable, U: P1 where U.A1 == T>: C1<T> {
}

with the following stack trace

0  swift                    0x0000000110d0e34b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x0000000110d0d636 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x0000000110d0e99f SignalHandler(int) + 287
3  libsystem_platform.dylib 0x00007fff96eea52a _sigtramp + 26
4  libsystem_platform.dylib 0x000000000ef7dcc6 _sigtramp + 2013870006
5  swift                    0x000000010e7e9dab swift::irgen::emitAssociatedTypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::AssociatedTypeDecl*, llvm::Value*, swift::ProtocolDecl*) + 43
6  swift                    0x000000010e7eb9a9 llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 361
7  swift                    0x000000010e879450 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 240
8  swift                    0x000000010e7e9d72 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 130
9  swift                    0x000000010e87955e swift::irgen::emitWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanType, llvm::Value**, swift::ProtocolConformanceRef) + 62
10 swift                    0x000000010e87950f swift::irgen::emitWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanType, swift::ProtocolConformanceRef) + 31
11 swift                    0x000000010e861936 void llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>::callback_fn<(anonymous namespace)::GenericArguments::collect(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::BoundGenericType>)::'lambda'(unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>(long, unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>) + 38
12 swift                    0x000000010e87a0ee swift::irgen::GenericTypeRequirements::enumerateFulfillments(swift::irgen::IRGenModule&, llvm::ArrayRef<swift::Substitution>, llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>) + 606
13 swift                    0x000000010e86166b emitNominalMetadataRef(swift::irgen::IRGenFunction&, swift::NominalTypeDecl*, swift::CanType) + 299
14 swift                    0x000000010e8533d9 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType) + 73
15 swift                    0x000000010e855037 swift::irgen::emitClassHeapMetadataRef(swift::irgen::IRGenFunction&, swift::CanType, swift::irgen::MetadataValueType, bool) + 167
16 swift                    0x000000010e857f4d swift::irgen::emitClassMetadata(swift::irgen::IRGenModule&, swift::ClassDecl*, swift::irgen::StructLayout const&, swift::irgen::ClassLayout const&) + 7341
17 swift                    0x000000010e809b93 swift::irgen::IRGenModule::emitClassDecl(swift::ClassDecl*) + 163
18 swift                    0x000000010e811635 swift::irgen::IRGenModule::emitSourceFile(swift::SourceFile&, unsigned int) + 117
19 swift                    0x000000010e8a19f5 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1253
20 swift                    0x000000010e8a083d swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&) + 621
21 swift                    0x000000010e7ddc4a swift::RunImmediately(swift::CompilerInstance&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) + 154
22 swift                    0x000000010e7cf2e4 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 15732
23 swift                    0x000000010e7ca619 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2873
24 swift                    0x000000010e7986c4 main + 2852
25 libdyld.dylib            0x00007fff8d79b5ad start + 1
26 libdyld.dylib            0x000000000000000c start + 1921403488
Stack dump:
0.  Program arguments: /Users/banjun/Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret swift3-preview1-crash-example1.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode731.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -color-diagnostics -module-name main 
1.  While emitting IR for source file swift3-preview1-crash-example1.swift
2.  While emitting class metadata for 'C2' at swift3-preview1-crash-example1.swift:13:1
zsh: segmentation fault   swift3-preview1-crash-example1.swift
@belkadan
Copy link
Contributor

@rjmccall, look familiar?

@CodaFi
Copy link
Member Author

CodaFi commented Jun 21, 2016

A fix is at apple/swift#3093.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added crash Bug: A crash, i.e., an abnormal termination of software generics Feature: generic declarations and types and removed new feature labels Nov 17, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software generics Feature: generic declarations and types IRGen LLVM IR generation
Projects
None yet
Development

No branches or pull requests

3 participants