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-12878] Crash when Codable type contains a property of its own type #55325

Open
swift-ci opened this issue May 25, 2020 · 1 comment
Open
Assignees
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 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-12878
Radar None
Original Reporter mlilek (JIRA User)
Type Bug
Status In Progress
Resolution
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee @theblixguy
Priority Medium

md5: 412154148f41f014585c290b3d5f40ec

Issue Description:

The following code crashes swiftc on both Swift 5.2 (Xcode 11.4) and the latest 2020-05-24 trunk snapshot. It should probably throw an error message or something more graceful.

class Thing: Codable {
    let shared = Thing()
}
matt@Mattbook-Pro Desktop % xcrun --toolchain swift swiftc --version
Apple Swift version 5.3-dev (LLVM f48b268b00, Swift 95819188a9)
Target: x86_64-apple-darwin19.5.0

matt@Mattbook-Pro Desktop % xcrun --toolchain swift swiftc Test.swift 
Assertion failed: (Conformance->getWitnessUncached(requirement).getDecl() == match.Witness && "Deduced different witnesses?"), function recordWitness, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/Sema/TypeCheckProtocol.cpp, line 2510.
Stack dump:
0.  Program arguments: /Users/matt/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-05-24-a.xctoolchain/usr/bin/swift -frontend -c -primary-file Test.swift -target x86_64-apple-darwin19.5.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -target-sdk-version 10.15.4 -module-name Test -o /var/folders/rt/1wp6wmcx3xg7hq8m7r97sr880000gn/T/Test-96f4c1.o 
1.  Apple Swift version 5.3-dev (LLVM f48b268b00, Swift 95819188a9)
2.  While evaluating request TypeCheckSourceFileRequest(source_file "Test.swift")
3.  While type-checking 'Thing' (at Test.swift:1:1)
4.  While evaluating request EmittedMembersRequest(Test.(file).Thing@Test.swift:1:7)
5.  While type-checking protocol conformance to 'Decodable' (in module 'Swift') for type 'Thing' (declared at [Test.swift:1:1 - line:3:1] RangeText="class Thing: Codable {
    let shared = Thing()
")
0  swift                    0x00000001057fa4f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x00000001057f9745 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x00000001057faac6 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff6c4395fd _sigtramp + 29
4  swift                    0x00000001080aa8c8 cmark_strbuf__initbuf + 173451
5  libsystem_c.dylib        0x00007fff6c30f808 abort + 120
6  libsystem_c.dylib        0x00007fff6c30eac6 err + 0
7  swift                    0x0000000105c06383 swift::ConformanceChecker::recordWitness(swift::ValueDecl*, swift::RequirementMatch const&) (.cold.2) + 35
8  swift                    0x0000000102366068 swift::ConformanceChecker::recordWitness(swift::ValueDecl*, swift::RequirementMatch const&) + 168
9  swift                    0x0000000102369aa7 swift::ConformanceChecker::resolveWitnessViaDerivation(swift::ValueDecl*) + 311
10 swift                    0x000000010236ac03 swift::ConformanceChecker::resolveValueWitnesses() + 387
11 swift                    0x00000001023658e5 swift::ConformanceChecker::checkConformance(swift::MissingWitnessDiagnosisKind) + 245
12 swift                    0x000000010236410d swift::MultiConformanceChecker::checkIndividualConformance(swift::NormalProtocolConformance*, bool) + 8909
13 swift                    0x0000000102361cc2 swift::MultiConformanceChecker::checkAllConformances() + 114
14 swift                    0x000000010236b80e swift::TypeChecker::checkConformance(swift::NormalProtocolConformance*) + 302
15 swift                    0x0000000102313b11 swift::EmittedMembersRequest::evaluate(swift::Evaluator&, swift::ClassDecl*) const + 209
16 swift                    0x000000010265b079 llvm::Expected<swift::EmittedMembersRequest::OutputType> swift::Evaluator::getResultUncached<swift::EmittedMembersRequest>(swift::EmittedMembersRequest const&) + 457
17 swift                    0x000000010265adea llvm::Expected<swift::EmittedMembersRequest::OutputType> swift::Evaluator::getResultCached<swift::EmittedMembersRequest, (void*)0>(swift::EmittedMembersRequest const&) + 154
18 swift                    0x000000010261b91a swift::EmittedMembersRequest::OutputType swift::evaluateOrDefault<swift::EmittedMembersRequest>(swift::Evaluator&, swift::EmittedMembersRequest, swift::EmittedMembersRequest::OutputType) + 42
19 swift                    0x0000000102332372 (anonymous namespace)::DeclChecker::visitClassDecl(swift::ClassDecl*) + 82
20 swift                    0x000000010232e83f (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 159
21 swift                    0x000000010232e782 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 130
22 swift                    0x00000001023cde38 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 200
23 swift                    0x00000001023cee15 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 453
24 swift                    0x00000001023ceb44 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 52
25 swift                    0x00000001023ceab6 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 118
26 swift                    0x00000001023cdc80 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 32
27 swift                    0x0000000101752068 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t, swift::OptionSet<swift::SourceFile::ParsingFlags, unsigned char>) + 680
28 swift                    0x0000000101677e51 performCompile(swift::CompilerInstance&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 2097
29 swift                    0x000000010167666d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3533
30 swift                    0x0000000101612ead main + 861
31 libdyld.dylib            0x00007fff6c240cc9 start + 1
32 libdyld.dylib            0x0000000000000011 start + 18446603338701861705
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
@theblixguy
Copy link
Collaborator

#32028

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants