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-10741] Compiler crashes with protocols and generics + default extension (Assertion failed: (!isInvalid()) #53133

Closed
swift-ci opened this issue May 22, 2019 · 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

Previous ID SR-10741
Radar rdar://problem/56834886
Original Reporter ipodishima (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Xcode 10.2.1 (10E1001)

Toolchain: Swift 5.1 Snapshot 2019-05-09 (a)

When using the default toolchain from Xcode 10.2.1, I get a Segmentation fault: 11

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

md5: 7fdd9df278adf93b643010b7472d86d9

duplicates:

  • SR-8814 GenericSignatureBuilder should re-introduce conformance requirements when adding a superclass requirement

Issue Description:

Hi there

I have a compiler crash with my project when I try to move it to Swift 5.0 (I get a Segmentation fault: 11). It's still happening with swift-5.1 toolchain but I get an Abort trap: 6 instead.

I saw SR-10128 which might be close to what I encounter (I'll let you set the link if needed because testing it with the 5.1 do not resolve my issue).

Assertion failed: (!isInvalid()), function getRequirement, file /Users/buildnode/jenkins/workspace/oss-swift-5.1-package-osx/swift/lib/AST/ProtocolConformance.cpp, line 77.
Stack dump:
[...]
1. While emitting IR SIL function "@$s9TestCrash17TableViewDelegateCyqd__GAA04ListdE6TraitsA2aEP6insets12forSectionAtSo12UIEdgeInsetsVSi_tFTW".
for 'insets(forSectionAt:)' (at /Users/marianpaul/Desktop/TestCrash/TestCrash/ListView/Protocols/ListViewDelegateTraits.swift:80:5)
0  swift                    0x0000000104970725 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010496f9e5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000104970d08 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff7796eb3d _sigtramp + 29
4  swift                    0x0000000105bd41f5 cmark_strbuf__initbuf + 125568
5  libsystem_c.dylib        0x00007fff7782c1c9 abort + 127
6  libsystem_c.dylib        0x00007fff777f4868 basename_r + 0
7  swift                    0x0000000101d039cf swift::ProtocolConformanceRef::getRequirement() const + 63
8  swift                    0x0000000100f39a66 void llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>::callback_fn<swift::irgen::FulfillmentMap::searchNominalTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&)::$_1>(long, unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>) + 1142
9  swift                    0x000000010101802f swift::irgen::GenericTypeRequirements::enumerateFulfillments(swift::irgen::IRGenModule&, swift::SubstitutionMap, llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>) + 239
10 swift                    0x0000000100f38b65 swift::irgen::FulfillmentMap::searchNominalTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 245
11 swift                    0x0000000100f388b8 swift::irgen::FulfillmentMap::searchTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::irgen::IsExact_t, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 840
12 swift                    0x00000001010aed92 swift::irgen::LocalTypeDataCache::addAbstractForTypeMetadata(swift::irgen::IRGenFunction&, swift::CanType, swift::irgen::IsExact_t, swift::irgen::MetadataResponse) + 114
13 swift                    0x00000001010aece0 swift::irgen::IRGenFunction::bindLocalTypeDataFromTypeMetadata(swift::CanType, swift::irgen::IsExact_t, llvm::Value*, swift::MetadataState) + 272
14 swift                    0x0000000101016804 swift::irgen::emitPolymorphicParameters(swift::irgen::IRGenFunction&, swift::SILFunction&, swift::irgen::Explosion&, swift::irgen::WitnessMetadata*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 820
15 swift                    0x0000000101077cd0 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 6000
16 swift                    0x0000000100f814eb swift::irgen::IRGenerator::emitLazyDefinitions() + 1243
17 swift                    0x00000001010529c5 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**) + 1573
18 swift                    0x0000000101052e46 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
19 swift                    0x0000000100ee51b7 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 14599
20 swift                    0x0000000100ee0852 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2978
21 swift                    0x0000000100e876c8 main + 696
22 libdyld.dylib            0x00007fff77783ed9 start + 1
error: Abort trap: 6

I attached a project which demos the crash. All the code might not be required but I isolated the parts from my project which are causing an issue.

@swift-ci
Copy link
Collaborator Author

Comment by Marian Paul (JIRA)

So, I made some progress on this issue since otherwise I'm stuck to make my project evolving.

As a reminder, the idea of this code was to share duplicated behaviors between table views and collection views. Our base code is handling both of them with the same inputs and outputs. That's the purpose of ListView.

That being said, we have two protocols (ListViewDataSourceTraits & ListViewDelegateTraits) for which there are extensions. These extensions implement default behaviors for some of the protocol's methods. And that's why it is not working.
If I remove the code in the extension and duplicate it in TableViewDataSource, CollectionViewDataSource, ... then the compiler stops yelling at me.

I kind of have no idea why though!

@belkadan
Copy link
Contributor

belkadan commented Nov 2, 2019

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