Skip to content

[SR-11582] Crash when encoding empty decodable class #53987

@theblixguy

Description

@theblixguy
Previous ID SR-11582
Radar None
Original Reporter @theblixguy
Type Bug
Environment

Swift version 5.1-dev (LLVM 1f54080bb6, Swift ce0c66b1cd)
Target: x86_64-apple-darwin19.0.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Codable, CompilerCrash, DerivedConformance
Assignee bendjones (JIRA)
Priority Medium

md5: f198bfeb40c5eec02635c141a9e3ecf7

Issue Description:

A really simple reproducer:

class Foo: Decodable {}
class Bar: Foo, Encodable {}
Should have found at least 1 var decl
UNREACHABLE executed at /Users/suyashsrijan/Documents/swift-src/swift/lib/Sema/DerivedConformanceCodable.cpp:543!
Stack dump:
0.  Program arguments: ./swiftc -frontend -typecheck /Users/suyashsrijan/Desktop/test.swift
1.  Swift version 5.1-dev (LLVM 1f54080bb6, Swift ce0c66b1cd)
2.  While evaluating request TypeCheckFunctionBodyUntilRequest(test.(file).Bar.encode(to:), )
3.  While type-checking 'encode(to:)' (in module 'test')
4.  While evaluating request ParseAbstractFunctionBodyRequest(test.(file).Bar.encode(to:))
0  swiftc                   0x0000000104fffa55 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swiftc                   0x0000000104ffed05 llvm::sys::RunSignalHandlers() + 85
2  swiftc                   0x0000000105000038 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff69a23b1d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000000054 _sigtramp + 2522727764
5  libsystem_c.dylib        0x00007fff698f9a08 abort + 120
6  swiftc                   0x00000001061f503e llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 462
7  swiftc                   0x0000000101dad3b8 lookupVarDeclForCodingKeysCase(swift::DeclContext*, swift::EnumElementDecl*, swift::NominalTypeDecl*) + 456
8  swiftc                   0x0000000101dac4bd deriveBodyEncodable_encode(swift::AbstractFunctionDecl*, void*) + 1213
9  swiftc                   0x00000001020f0a91 swift::ParseAbstractFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 305
10 swiftc                   0x00000001020f0b41 swift::SimpleRequest<swift::ParseAbstractFunctionBodyRequest, swift::BraceStmt* (swift::AbstractFunctionDecl*), (swift::CacheKind)2>::evaluateRequest(swift::ParseAbstractFunctionBodyRequest const&, swift::Evaluator&) + 17
11 swiftc                   0x0000000102241110 llvm::Expected<swift::ParseAbstractFunctionBodyRequest::OutputType> swift::Evaluator::getResultUncached<swift::ParseAbstractFunctionBodyRequest>(swift::ParseAbstractFunctionBodyRequest const&) + 384
12 swiftc                   0x0000000102240e72 llvm::Expected<swift::ParseAbstractFunctionBodyRequest::OutputType> swift::Evaluator::getResultCached<swift::ParseAbstractFunctionBodyRequest, (void*)0>(swift::ParseAbstractFunctionBodyRequest const&) + 66
13 swiftc                   0x000000010224032b llvm::Expected<swift::ParseAbstractFunctionBodyRequest::OutputType> swift::Evaluator::operator()<swift::ParseAbstractFunctionBodyRequest>(swift::ParseAbstractFunctionBodyRequest const&) + 107
14 swiftc                   0x00000001022052f3 swift::ParseAbstractFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::ParseAbstractFunctionBodyRequest>(swift::Evaluator&, swift::ParseAbstractFunctionBodyRequest, swift::ParseAbstractFunctionBodyRequest::OutputType) + 35
15 swiftc                   0x0000000101eaf317 swift::TypeCheckFunctionBodyUntilRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*, swift::SourceLoc) const + 359
16 swiftc                   0x0000000101eacfa5 swift::SimpleRequest<swift::TypeCheckFunctionBodyUntilRequest, bool (swift::AbstractFunctionDecl*, swift::SourceLoc), (swift::CacheKind)1>::evaluateRequest(swift::TypeCheckFunctionBodyUntilRequest const&, swift::Evaluator&) + 21
17 swiftc                   0x0000000101eb7767 llvm::Expected<swift::TypeCheckFunctionBodyUntilRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyUntilRequest>(swift::TypeCheckFunctionBodyUntilRequest const&) + 391
18 swiftc                   0x0000000101eb72a0 llvm::Expected<swift::TypeCheckFunctionBodyUntilRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyUntilRequest, (void*)0>(swift::TypeCheckFunctionBodyUntilRequest const&) + 240
19 swiftc                   0x0000000101eb65bb llvm::Expected<swift::TypeCheckFunctionBodyUntilRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckFunctionBodyUntilRequest>(swift::TypeCheckFunctionBodyUntilRequest const&) + 107
20 swiftc                   0x0000000101eafe76 swift::TypeCheckFunctionBodyUntilRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyUntilRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyUntilRequest, swift::TypeCheckFunctionBodyUntilRequest::OutputType) + 38
21 swiftc                   0x0000000101eaf174 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 36
22 swiftc                   0x0000000101edbfc8 typeCheckFunctionsAndExternalDecls(swift::SourceFile&, swift::TypeChecker&) + 312
23 swiftc                   0x0000000101edc9df swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1775
24 swiftc                   0x0000000101633d39 swift::CompilerInstance::parseAndTypeCheckMainFileUpTo(swift::SourceFile::ASTStage_t, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 489
25 swiftc                   0x00000001016329c7 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 519
26 swiftc                   0x00000001016321cd swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 621
27 swiftc                   0x000000010141a462 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1650
28 swiftc                   0x0000000101418e86 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3046
29 swiftc                   0x00000001013c2af9 main + 729
30 libdyld.dylib            0x00007fff69822405 start + 1
31 libdyld.dylib            0x0000000000000004 start + 2524830720
zsh: abort      ./swiftc -frontend -typecheck ~/Desktop/test.swift

Metadata

Metadata

Assignees

No one assigned

    Labels

    CodableArea → standard library: `Codable` and co.bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwarederived conformancesFeature → protocol → conformances: derived conformances aka synthesized conformances

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions