swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.25k stars 10.32k forks source link

[SR-5092] Compiler crash when referencing a Codable object with self-defined CodingKeys enum #47668

Open swift-ci opened 7 years ago

swift-ci commented 7 years ago
Previous ID SR-5092
Radar rdar://problem/32567886
Original Reporter kylehickinson (JIRA User)
Type Bug

Attachment: Download

Environment swift-4.0-DEVELOPMENT-SNAPSHOT-2017-06-02-a.xctoolchain
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash | |Assignee | @itaiferber | |Priority | Medium | md5: 99c427b8ca101ef18660a6339ffaf120

Issue Description:

The crash is an assertion coming from (isError) swift::DerivedConformance::deriveCodingKey(swift::TypeChecker&, swift::Decl*, swift::NominalTypeDecl*, swift::ValueDecl*)

It stems from the issue where you define the enum "CodingKeys" yourself — instead of allowing the compiler to generate it — within your Codable object. The object compiles fine, but referencing it from a different file causes a Type not yet validated assertion.

I've attached a sample project and crash stacktrace, and sorry if this is already known and part of https://github.com/apple/swift/pull/8125

Model.swift:

/// A basic model
public struct Model: Codable {

  /// A property (which JSON will match to "property_one")
  public var propertyOne: Int
}

extension Model {
  /// By defining this ourselves (regardless of if its an extension), we create 
  /// a compiler crash (assertion)
  ///
  /// If we remove this, (or define our own enum and implement init(from:) the
  /// crash doesn't happen anymore.
  enum CodingKeys: String, CodingKey {
    // Remap
    case propertyOne = "property_one"
  }
}

Client.swift:

public class Client {
  init() {
    // Crash
    let m = Model(propertyOne: 1)
  }
}
belkadan commented 7 years ago

Thanks, Kyle! cc @itaiferber

@swift-ci create

swift-ci commented 7 years ago

Comment by Kyle Hickinson (JIRA)

Just an FYI: This seems to be fixed in Xcode 9 beta 1 🙂

belkadan commented 7 years ago

Ah, I believe the Xcode beta has assertions turned off. So it's possible you're just squeaking by, or even that the compiler is emitting nonsense, which means it's still worth it for us to look into this!

itaiferber commented 7 years ago

I can't reproduce this on the latest swift-4.0-branch, swift-4.0-branch-06-02-2017 branch, or master (with all assertions turned on). I feel pretty confident in saying this probably got fixed soon after that toolchain was put out.

kylehickinson (JIRA User) Have you been able to reproduce this since?

swift-ci commented 7 years ago

Comment by Kyle Hickinson (JIRA)

Just tried this on Xcode 8.3.2 using switch swift Jun 6th Swift 4 Toolchain and still got the assertion crash (using the uploaded CodableCompilerCrash.zip project)

Assertion failed: (wasValidated() && "Type not yet validated"), function isError, file /Users/buildnode/jenkins/workspace/oss-swift-4.0-package-osx/swift/lib/AST/Type.cpp, line 69.
0  swift                    0x000000010fb7e838 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010fb7d806 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x000000010fb7edf9 SignalHandler(int) + 361
3  libsystem_platform.dylib 0x00007fff8f245b3a _sigtramp + 26
4  libsystem_platform.dylib 0x0000000000000003 _sigtramp + 1893442787
5  libsystem_c.dylib        0x00007fff8f0ca420 abort + 129
6  libsystem_c.dylib        0x00007fff8f091893 basename_r + 0
7  swift                    0x000000010d9b7c66 swift::TypeLoc::isError() const + 54
8  swift                    0x000000010d7922f6 swift::DerivedConformance::deriveCodingKey(swift::TypeChecker&, swift::Decl*, swift::NominalTypeDecl*, swift::ValueDecl*) + 198
9  swift                    0x000000010d836498 (anonymous namespace)::ConformanceChecker::resolveWitnessViaDerivation(swift::ValueDecl*) + 136
10 swift                    0x000000010d82cb2d (anonymous namespace)::MultiConformanceChecker::checkAllConformances() + 3261
11 swift                    0x000000010d82bdb4 swift::TypeChecker::checkConformance(swift::NormalProtocolConformance*) + 196
12 swift                    0x000000010d8766bb typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 1435
13 swift                    0x000000010d87715e swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1806
14 swift                    0x000000010d3c9109 swift::CompilerInstance::performSema() + 3881
15 swift                    0x000000010c960c1f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 2431
16 swift                    0x000000010c95f1ca swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2650
17 swift                    0x000000010c91bca0 main + 3312
18 libdyld.dylib            0x00007fff8f036235 start + 1

Just noticed though that there's a Jun 7th snapshot to download so I will download that a bit later (currently tethering commuting from work) and test it out.

swift-ci commented 7 years ago

Comment by Kyle Hickinson (JIRA)

Unfortunately I'm still getting the assertion with June 7th release, here is the build log (I tried using xcodebuild this time)

20:40 CodableCompilerCrash ❯ xcodebuild TOOLCHAINS=org.swift.4020170607a
Build settings from command line:
    TOOLCHAINS = org.swift.4020170607a

Build Preparation
Build task concurrency set to 8 via user default IDEBuildOperationMaxNumberOfConcurrentCompileTasks

=== BUILD TARGET CodableCompilerCrash OF PROJECT CodableCompilerCrash WITH THE DEFAULT CONFIGURATION (Release) ===

Check dependencies

CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
    cd /Users/kyle/Downloads/CodableCompilerCrash
    export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/sbin:/Users/kyle/.rvm/bin"
    export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk
    export TOOLCHAINS=org.swift.4020170607a
    /Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-06-07-a.xctoolchain/usr/bin/swiftc -incremental -module-name CodableCompilerCrash -O -whole-module-optimization -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -target armv7-apple-ios10.3 -g -Xfrontend -serialize-debugging-options -I /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -F /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -c -num-threads 8 /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Client.swift /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Model.swift -output-file-map /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/CodableCompilerCrash-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/CodableCompilerCrash.swiftmodule -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-generated-files.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-own-target-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-project-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos/include -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources/armv7 -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/CodableCompilerCrash-Swift.h -import-underlying-module -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/kyle/Downloads/CodableCompilerCrash

CompileSwift normal armv7
    cd /Users/kyle/Downloads/CodableCompilerCrash
    /Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-06-07-a.xctoolchain/usr/bin/swift -frontend -c /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Client.swift /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Model.swift -target armv7-apple-ios10.3 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -I /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -F /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -g -import-underlying-module -serialize-debugging-options -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-generated-files.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-own-target-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-project-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos/include -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources/armv7 -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/kyle/Downloads/CodableCompilerCrash -emit-module-doc-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/CodableCompilerCrash.swiftdoc -serialize-diagnostics-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/Client.dia -O -module-name CodableCompilerCrash -emit-module-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/CodableCompilerCrash.swiftmodule -emit-objc-header-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/CodableCompilerCrash-Swift.h -emit-dependencies-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/Client.d -num-threads 8 -o /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/Client.o -o /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/Model.o
/Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Client.swift:14:9: warning: initialization of immutable value 'm' was never used; consider replacing with assignment to '_' or removing it
    let m = Model(propertyOne: 1)
    ~~~~^
    _
Assertion failed: (wasValidated() && "Type not yet validated"), function isError, file /Users/buildnode/jenkins/workspace/oss-swift-4.0-package-osx/swift/lib/AST/Type.cpp, line 69.
0  swift                    0x000000010d08a6b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010d089686 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x000000010d08ac79 SignalHandler(int) + 361
3  libsystem_platform.dylib 0x00007fff8f245b3a _sigtramp + 26
4  libsystem_platform.dylib 0x0000000000000003 _sigtramp + 1893442787
5  libsystem_c.dylib        0x00007fff8f0ca420 abort + 129
6  libsystem_c.dylib        0x00007fff8f091893 basename_r + 0
7  swift                    0x000000010aec3ae6 swift::TypeLoc::isError() const + 54
8  swift                    0x000000010ac9e0d6 swift::DerivedConformance::deriveCodingKey(swift::TypeChecker&, swift::Decl*, swift::NominalTypeDecl*, swift::ValueDecl*) + 198
9  swift                    0x000000010ad422c8 (anonymous namespace)::ConformanceChecker::resolveWitnessViaDerivation(swift::ValueDecl*) + 136
10 swift                    0x000000010ad3895d (anonymous namespace)::MultiConformanceChecker::checkAllConformances() + 3261
11 swift                    0x000000010ad37be4 swift::TypeChecker::checkConformance(swift::NormalProtocolConformance*) + 196
12 swift                    0x000000010ad824eb typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 1435
13 swift                    0x000000010ad82f8e swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1806
14 swift                    0x000000010a8d4769 swift::CompilerInstance::performSema() + 3881
15 swift                    0x0000000109e6c27f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 2431
16 swift                    0x0000000109e6a82a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2650
17 swift                    0x0000000109e26aa0 main + 3312
18 libdyld.dylib            0x00007fff8f036235 start + 1
19 libdyld.dylib            0x0000000000000042 start + 1895603726
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-06-07-a.xctoolchain/usr/bin/swift -frontend -c /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Client.swift /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Model.swift -target armv7-apple-ios10.3 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -I /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -F /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -g -import-underlying-module -serialize-debugging-options -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-generated-files.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-own-target-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-project-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos/include -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources/armv7 -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/kyle/Downloads/CodableCompilerCrash -emit-module-doc-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/CodableCompilerCrash.swiftdoc -serialize-diagnostics-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/Client.dia -O -module-name CodableCompilerCrash -emit-module-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/CodableCompilerCrash.swiftmodule -emit-objc-header-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/CodableCompilerCrash-Swift.h -emit-dependencies-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/Client.d -num-threads 8 -o /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/Client.o -o /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/armv7/Model.o 

<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)
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
    cd /Users/kyle/Downloads/CodableCompilerCrash
    export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/sbin:/Users/kyle/.rvm/bin"
    export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk
    export TOOLCHAINS=org.swift.4020170607a
    /Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-06-07-a.xctoolchain/usr/bin/swiftc -incremental -module-name CodableCompilerCrash -O -whole-module-optimization -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -target arm64-apple-ios10.3 -g -Xfrontend -serialize-debugging-options -I /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -F /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -c -num-threads 8 /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Client.swift /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Model.swift -output-file-map /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/CodableCompilerCrash-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/CodableCompilerCrash.swiftmodule -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-generated-files.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-own-target-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-project-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos/include -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources/arm64 -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/CodableCompilerCrash-Swift.h -import-underlying-module -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/kyle/Downloads/CodableCompilerCrash
<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)

CompileSwift normal arm64
    cd /Users/kyle/Downloads/CodableCompilerCrash
    /Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-06-07-a.xctoolchain/usr/bin/swift -frontend -c /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Client.swift /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Model.swift -target arm64-apple-ios10.3 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -I /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -F /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -g -import-underlying-module -serialize-debugging-options -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-generated-files.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-own-target-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-project-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos/include -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources/arm64 -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/kyle/Downloads/CodableCompilerCrash -emit-module-doc-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/CodableCompilerCrash.swiftdoc -serialize-diagnostics-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/Client.dia -O -module-name CodableCompilerCrash -emit-module-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/CodableCompilerCrash.swiftmodule -emit-objc-header-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/CodableCompilerCrash-Swift.h -emit-dependencies-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/Client.d -num-threads 8 -o /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/Client.o -o /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/Model.o
/Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Client.swift:14:9: warning: initialization of immutable value 'm' was never used; consider replacing with assignment to '_' or removing it
    let m = Model(propertyOne: 1)
    ~~~~^
    _
Assertion failed: (wasValidated() && "Type not yet validated"), function isError, file /Users/buildnode/jenkins/workspace/oss-swift-4.0-package-osx/swift/lib/AST/Type.cpp, line 69.
0  swift                    0x000000010bf056b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010bf04686 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x000000010bf05c79 SignalHandler(int) + 361
3  libsystem_platform.dylib 0x00007fff8f245b3a _sigtramp + 26
4  libsystem_platform.dylib 0x0000000000000003 _sigtramp + 1893442787
5  libsystem_c.dylib        0x00007fff8f0ca420 abort + 129
6  libsystem_c.dylib        0x00007fff8f091893 basename_r + 0
7  swift                    0x0000000109d3eae6 swift::TypeLoc::isError() const + 54
8  swift                    0x0000000109b190d6 swift::DerivedConformance::deriveCodingKey(swift::TypeChecker&, swift::Decl*, swift::NominalTypeDecl*, swift::ValueDecl*) + 198
9  swift                    0x0000000109bbd2c8 (anonymous namespace)::ConformanceChecker::resolveWitnessViaDerivation(swift::ValueDecl*) + 136
10 swift                    0x0000000109bb395d (anonymous namespace)::MultiConformanceChecker::checkAllConformances() + 3261
11 swift                    0x0000000109bb2be4 swift::TypeChecker::checkConformance(swift::NormalProtocolConformance*) + 196
12 swift                    0x0000000109bfd4eb typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 1435
13 swift                    0x0000000109bfdf8e swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1806
14 swift                    0x000000010974f769 swift::CompilerInstance::performSema() + 3881
15 swift                    0x0000000108ce727f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 2431
16 swift                    0x0000000108ce582a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2650
17 swift                    0x0000000108ca1aa0 main + 3312
18 libdyld.dylib            0x00007fff8f036235 start + 1
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-06-07-a.xctoolchain/usr/bin/swift -frontend -c /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Client.swift /Users/kyle/Downloads/CodableCompilerCrash/CodableCompilerCrash/Model.swift -target arm64-apple-ios10.3 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -I /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -F /Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos -g -import-underlying-module -serialize-debugging-options -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-generated-files.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-own-target-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/CodableCompilerCrash-project-headers.hmap -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/Release-iphoneos/include -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources/arm64 -Xcc -I/Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/DerivedSources -Xcc -ivfsoverlay -Xcc /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/kyle/Downloads/CodableCompilerCrash -emit-module-doc-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/CodableCompilerCrash.swiftdoc -serialize-diagnostics-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/Client.dia -O -module-name CodableCompilerCrash -emit-module-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/CodableCompilerCrash.swiftmodule -emit-objc-header-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/CodableCompilerCrash-Swift.h -emit-dependencies-path /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/Client.d -num-threads 8 -o /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/Client.o -o /Users/kyle/Downloads/CodableCompilerCrash/build/CodableCompilerCrash.build/Release-iphoneos/CodableCompilerCrash.build/Objects-normal/arm64/Model.o 

** BUILD FAILED **

The following build commands failed:
    CompileSwift normal armv7
    CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
    CompileSwift normal arm64
(4 failures)
liscio commented 7 years ago

I am experiencing the same bug as this under Linux inside a Docker container. Using the above code, but modified to exist in a swift package, I have reproduced this bug using swift-4.0-DEVELOPMENT-SNAPSHOT-2017-07-11.

Requirements: A Mac, with docker installed (see https://www.docker.com/docker-mac)

To reproduce:

1. Grab the attached zip file: testpkg.zip

  1. Run the following command at the Terminal:
itaiferber commented 7 years ago

I don't have time to look at the moment, but I believe the manifestation of this bug will go away with one of the changes in PR-10723. It's orthogonal to the issue that the PR is trying to solve, but the additional eager validation in `CodingKeys` should prevent this assertion from triggering.

liscio commented 7 years ago

@itaiferber: No worries—I will keep an eye on that PR, then. Once merged and available in a snapshot, I'll re-test the larger, more complicated package where I first got hit by this bug.

For the sake of completion, I managed to reproduce this on my Mac using the same snapshot. Previous (successful) runs were using Xcode 9b3, which is strange.

I just ran this command in the testpkg folder:

itaiferber commented 7 years ago

Yeah, this would be present regardless of OS version since it's happening in compiler validation of the CodingKeys enum. Thanks for replicating the crash, and hopefully I can get to resolving this soon.

itaiferber commented 7 years ago

kylehickinson (JIRA User) @liscio Apologies that this hasn't been updated in a while. Has this reproduced on a recent build of Swift/Xcode beta? Some work was done on type validation in PR-11151 that might be relevant to this; I also just tried to reproduce this in Xcode with a recent toolchain and this isn't reproducing for me.