kareman / SwiftShell

A Swift framework for shell scripting.
https://kareman.github.io/SwiftShell
MIT License
1.03k stars 87 forks source link

Final released Swift 5.3 crashes on compile #91

Closed briancordanyoung closed 4 years ago

briancordanyoung commented 4 years ago

I'm just starting to look in to this. But, I'm posting here for additional comments in case someone else finds a work around before I do.

Using public App Store release of Xcode 12.0 (12A7209) and Swift 5.3, The compiler crashes while processing SwiftShell.

1.  Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)
2.  While evaluating request TypeCheckSourceFileRequest(source_file "/<redacted>/.build/checkouts/SwiftShell/Sources/SwiftShell/Stream/Stream.swift")
3.  While type-checking 'FileHandleStream' (at /<redacted>/.build/checkouts/SwiftShell/Sources/SwiftShell/Stream/Stream.swift:207:8)
4.  While type-checking protocol conformance to 'TextOutputStreamable' (in module 'Swift') for type 'FileHandleStream' (declared at [/<redacted>/.build/checkouts/SwiftShell/Sources/SwiftShell/Stream/Stream.swift:207:8 - line:215:1] RangeText="class FileHandleStream: ReadableStream, WritableStream {
    public let filehandle: FileHandle
    public var encoding: String.Encoding

    public init(_ filehandle: FileHandle, encoding: String.Encoding) {
        self.filehandle = filehandle
        self.encoding = encoding
    }
")
0  swift                    0x0000000105743865 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x0000000105742865 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000105743e1f SignalHandler(int) + 111
3  libsystem_platform.dylib 0x00007fff7017b5fd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338635561504
5  swift                    0x0000000101fea0fb swift::constraints::ConstraintSystem::simplifyRestrictedConstraint(swift::constraints::ConversionRestrictionKind, swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 779
6  swift                    0x0000000101fd9c80 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 14960
7  swift                    0x0000000101fe4ec1 swift::constraints::ConstraintSystem::repairFailures(swift::Type, swift::Type, swift::constraints::ConstraintKind, llvm::SmallVectorImpl<swift::constraints::RestrictionOrFix>&, swift::constraints::ConstraintLocatorBuilder) + 12529
8  swift                    0x0000000101fd9c15 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 14853
9  swift                    0x0000000101fda039 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 15913
10 swift                    0x0000000101ffeaa0 swift::constraints::ConstraintSystem::addConstraintImpl(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) + 96
11 swift                    0x0000000101fd5b42 swift::constraints::ConstraintSystem::addConstraint(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) + 66
12 swift                    0x00000001022069bd llvm::Optional<swift::RequirementMatch> llvm::function_ref<llvm::Optional<swift::RequirementMatch> (swift::Type, swift::Type)>::callback_fn<swift::matchWitness(llvm::DenseMap<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*>, swift::RequirementEnvironment, llvm::DenseMapInfo<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*> >, llvm::detail::DenseMapPair<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::ProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*)::$_1>(long, swift::Type, swift::Type) + 93
13 swift                    0x00000001021e7dca swift::matchWitness(swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*, llvm::function_ref<std::__1::tuple<llvm::Optional<swift::RequirementMatch>, swift::Type, swift::Type> ()>, llvm::function_ref<llvm::Optional<swift::RequirementMatch> (swift::Type, swift::Type)>, llvm::function_ref<swift::RequirementMatch (bool, llvm::ArrayRef<swift::OptionalAdjustment>)>) + 8778
14 swift                    0x00000001021e9903 swift::matchWitness(llvm::DenseMap<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*>, swift::RequirementEnvironment, llvm::DenseMapInfo<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*> >, llvm::detail::DenseMapPair<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::ProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*) + 1187
15 swift                    0x00000001021ea452 swift::WitnessChecker::findBestWitness(swift::ValueDecl*, bool*, swift::NormalProtocolConformance*, llvm::SmallVectorImpl<swift::RequirementMatch>&, unsigned int&, unsigned int&, bool&) + 946
16 swift                    0x00000001021f4ac3 swift::ConformanceChecker::resolveWitnessViaLookup(swift::ValueDecl*) + 643
17 swift                    0x00000001021ef9a5 swift::MultiConformanceChecker::checkIndividualConformance(swift::NormalProtocolConformance*, bool) + 14773
18 swift                    0x00000001021eba93 swift::MultiConformanceChecker::checkAllConformances() + 147
19 swift                    0x00000001021fb617 swift::TypeChecker::checkConformancesInContext(swift::DeclContext*, swift::IterableDeclContext*) + 8295
20 swift                    0x00000001021ab89a (anonymous namespace)::DeclChecker::visitClassDecl(swift::ClassDecl*) + 8138
21 swift                    0x00000001021a3d93 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 2739
22 swift                    0x000000010226b621 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 753
23 swift                    0x000000010226e4a9 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 953
24 swift                    0x000000010226b1a4 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 164
25 swift                    0x00000001013e655b swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 6859
26 swift                    0x00000001012a72fd swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6845
27 swift                    0x000000010122bc07 main + 1255
28 libdyld.dylib            0x00007fff6ff82cc9 start + 1
29 libdyld.dylib            0x000000000000003c start + 18446603338637628276
IgorMuzyka commented 4 years ago

Experiencing the same issue.

kareman commented 4 years ago

Hi, I wasn't able to reproduce this issue.

Are you using the latest beta 5.1.0-beta.1? Are you using this project directly, or are you importing it into another project? If so, what type of product are you making? Are you importing this project as a swift package, or are you using the Xcode project? Are you running, testing, archiving?

briancordanyoung commented 4 years ago

I have a bunch of tasks related to updating to the latest released toolchain. So, I haven't gotten the time to dig in to this yet.. But, to answer you questions:

Are using the latest beta 5.1.0-beta.1?

Version 12.0 (12A7209) Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)

Are you using this project directly, or are you importing it into another project? If so, what type of product are you making? Are you importing this project as a swift package, or are using the Xcode project?

Importing via SPM to make an executable.

Are you running, testing, archiving?

All debug and release builds via swift build and Xcode.

alphatroya commented 4 years ago

As a way to reproduce this issue I suggest you to clone this repo and try to build it with Swift 5.3 (by swift build or generate xcodeproj for it).

I've tried to update dependency up to 5.0.1 and receive the same error.

kareman commented 4 years ago

Do you mean SwiftShell 5.0.1? Have you tried SwiftShell 5.1.0-beta.1 ?

alphatroya commented 4 years ago

Oh, my fault. I thought SPM support only Semantic Versioning tags.

Anyway, using 5.1.0-beta.1 did compile the tool well. I think this issue is resolved.

kareman commented 4 years ago

@briancordanyoung @IgorMuzyka does using SwiftShell 5.1.0-beta.1 solve this problem for you too? If so I’ll release 5.1.0 this week.

briancordanyoung commented 4 years ago

@kareman Yes! 5.1.0-beta.1 is a winner. Do you have any clue why?

kareman commented 4 years ago

Yes: https://github.com/kareman/SwiftShell/commit/bfddee7c951d255df30bc348a4ca4ed2bd098821

kareman commented 4 years ago

I just released 5.1.0.