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

Compiler crash when extending Obj-C code in Swift 5.8 / Xcode 14.3 RC 2 #64770

Open
simba909 opened this issue Mar 30, 2023 · 3 comments
Open
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 missing info Resolution: Is missing crucial info such as a test case or a concise description objective-c interop Feature: Interoperability with Objective-C swift 5.8

Comments

@simba909
Copy link

Description
When attempting to compile a project I'm working on with Swift 5.8 I run into a compiler crash. It fails on an extension in Swift adding a protocol conformance to an Objective-C type. I've managed to strip down the offending code to what I think is the bare minimum to reproduce the crash. Source repo here: https://github.com/simba909/swift-5.8-compilercrash

Steps to reproduce

  • Check out the repo linked above
  • Open the contained Swift package with Xcode 14.3 RC 2
  • Uncomment the protocol conformance in LegacyNode+Versionable.swift
  • Try to build the project

Expected behavior
The project should still fail to build (due to missing protocol requirements) but the compiler should be able to produce accurate diagnostics describing why compilation failed.

Environment

  • Swift compiler version info:
    swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
    Target: arm64-apple-macosx13.0
    
  • Xcode version info: Xcode 14.3, Build version 14E222b
  • Deployment target: iOS 16.4
@simba909 simba909 added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Mar 30, 2023
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler in itself compiler crash crash Bug: A crash, i.e., an abnormal termination of software swift 5.8 objective-c interop Feature: Interoperability with Objective-C missing info Resolution: Is missing crucial info such as a test case or a concise description labels Mar 31, 2023
@AnthonyLatsis
Copy link
Collaborator

Please provide a stack trace. We want to know what was going on if it gets fixed by chance along the way.

@simba909
Copy link
Author

@AnthonyLatsis Sure, here's the output of swift build with the 5.8 toolchain building the package linked in the description:

Building for debugging...
error: emit-module command failed due to signal 11 (use -v to see invocation)
error: compile command failed due to signal 11 (use -v to see invocation)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Applications/Xcode-14.3.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Users/simon/Developer/Linearity/CompilerCrash/Sources/CompilerCrash/LegacyNode+Versionable.swift /Users/simon/Developer/Linearity/CompilerCrash/Sources/CompilerCrash/Versionable.swift -target arm64-apple-macosx10.13 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode-14.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -I /Users/simon/Developer/Linearity/CompilerCrash/.build/arm64-apple-macosx/debug -I /Applications/Xcode-14.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode-14.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -module-cache-path /Users/simon/Developer/Linearity/CompilerCrash/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /Applications/Xcode-14.3.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Applications/Xcode-14.3.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=/Users/simon/Developer/Linearity/CompilerCrash/.build/arm64-apple-macosx/debug/Legacy.build/module.modulemap -Xcc -I -Xcc /Users/simon/Developer/Linearity/CompilerCrash/Sources/Legacy/include -module-name CompilerCrash -disable-clang-spi -target-sdk-version 13.3 -target-sdk-name macosx13.3 -emit-module-doc-path /Users/simon/Developer/Linearity/CompilerCrash/.build/arm64-apple-macosx/debug/CompilerCrash.swiftdoc -emit-module-source-info-path /Users/simon/Developer/Linearity/CompilerCrash/.build/arm64-apple-macosx/debug/CompilerCrash.swiftsourceinfo -emit-objc-header-path /Users/simon/Developer/Linearity/CompilerCrash/.build/arm64-apple-macosx/debug/CompilerCrash.build/CompilerCrash-Swift.h -emit-dependencies-path /Users/simon/Developer/Linearity/CompilerCrash/.build/arm64-apple-macosx/debug/CompilerCrash.build/CompilerCrash.emit-module.d -parse-as-library -o /Users/simon/Developer/Linearity/CompilerCrash/.build/arm64-apple-macosx/debug/CompilerCrash.swiftmodule -emit-abi-descriptor-path /Users/simon/Developer/Linearity/CompilerCrash/.build/arm64-apple-macosx/debug/CompilerCrash.abi.json
1.	Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
2.	Compiling with the current language version
3.	While evaluating request TypeCheckSourceFileRequest(source_file "/Users/simon/Developer/Linearity/CompilerCrash/Sources/CompilerCrash/LegacyNode+Versionable.swift")
4.	While type-checking extension of LegacyNode (at /Users/simon/Developer/Linearity/CompilerCrash/Sources/CompilerCrash/LegacyNode+Versionable.swift:4:1)
5.	While type-checking protocol conformance to 'Versionable' (at /Users/simon/Developer/Linearity/CompilerCrash/Sources/CompilerCrash/Versionable.swift:3:1) for type 'LegacyNode'
6.	While evaluating request ResolveImplicitMemberRequest(Legacy.(file).LegacyNode, resolve Decodable.init(from:))
7.	While type-checking protocol conformance to 'Decodable' (in module 'Swift') for type 'LegacyNode'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000109a63300 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000109a622e4 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000109a63910 SignalHandler(int) + 344
3  libsystem_platform.dylib 0x000000018976ea84 _sigtramp + 56
4  swift-frontend           0x0000000105a49ca0 swift::Type llvm::function_ref<swift::Type (swift::Type)>::callback_fn<swift::constraints::ConstraintSystem::simplifyTypeImpl(swift::Type, llvm::function_ref<swift::Type (swift::TypeVariableType*)>) const::$_34>(long, swift::Type) + 840
5  swift-frontend           0x00000001061b1e28 llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*, swift::TypePosition)>::callback_fn<swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const::$_18>(long, swift::TypeBase*, swift::TypePosition) + 24
6  swift-frontend           0x00000001061a6c30 swift::Type::transformWithPosition(swift::TypePosition, llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*, swift::TypePosition)>) const + 92
7  swift-frontend           0x0000000105a29c64 swift::constraints::ConstraintSystem::getFixedTypeRecursive(swift::Type, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>&, bool) const + 592
8  swift-frontend           0x000000010593cb44 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 104
9  swift-frontend           0x000000010596cc7c swift::constraints::ConstraintSystem::addConstraintImpl(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) + 476
10 swift-frontend           0x000000010596da54 swift::constraints::ConstraintSystem::addConstraint(swift::Requirement, swift::constraints::ConstraintLocatorBuilder, bool) + 276
11 swift-frontend           0x0000000105a2c438 swift::constraints::ConstraintSystem::openGenericRequirement(swift::DeclContext*, unsigned int, swift::Requirement const&, bool, swift::constraints::ConstraintLocatorBuilder, llvm::function_ref<swift::Type (swift::Type)>) + 468
12 swift-frontend           0x0000000105a2e82c swift::constraints::ConstraintSystem::getTypeOfMemberReference(swift::Type, swift::ValueDecl*, swift::DeclContext*, bool, swift::FunctionRefKind, swift::constraints::ConstraintLocator*, llvm::DenseMap<swift::GenericTypeParamType*, swift::TypeVariableType*, llvm::DenseMapInfo<swift::GenericTypeParamType*, void>, llvm::detail::DenseMapPair<swift::GenericTypeParamType*, swift::TypeVariableType*> >*) + 4576
13 swift-frontend           0x0000000105c15b08 std::__1::tuple<llvm::Optional<swift::RequirementMatch>, swift::Type, swift::Type> llvm::function_ref<std::__1::tuple<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*>, void>, llvm::detail::DenseMapPair<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::RootProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*)::$_0>(long) + 1648
14 swift-frontend           0x0000000105bf5b30 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>)>) + 848
15 swift-frontend           0x0000000105bf7afc 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*>, void>, llvm::detail::DenseMapPair<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::RootProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*) + 824
16 swift-frontend           0x0000000105bf8668 swift::WitnessChecker::findBestWitness(swift::ValueDecl*, bool*, swift::NormalProtocolConformance*, llvm::SmallVectorImpl<swift::RequirementMatch>&, unsigned int&, unsigned int&, bool&) + 800
17 swift-frontend           0x0000000105c033fc swift::ConformanceChecker::resolveWitnessViaLookup(swift::ValueDecl*) + 596
18 swift-frontend           0x0000000105c06b1c swift::ConformanceChecker::resolveValueWitnesses() + 1288
19 swift-frontend           0x0000000105bfd96c swift::MultiConformanceChecker::checkAllConformances() + 15632
20 swift-frontend           0x0000000105c099c0 swift::TypeChecker::checkConformance(swift::NormalProtocolConformance*) + 220
21 swift-frontend           0x0000000105b678d4 llvm::Expected<swift::ResolveImplicitMemberRequest::OutputType> swift::Evaluator::getResultUncached<swift::ResolveImplicitMemberRequest>(swift::ResolveImplicitMemberRequest const&) + 516
22 swift-frontend           0x0000000105fa2bf8 swift::NominalTypeDecl::synthesizeSemanticMembersIfNeeded(swift::DeclName) + 536
23 swift-frontend           0x0000000105bf7dec swift::WitnessChecker::lookupValueWitnesses(swift::ValueDecl*, bool*) + 180
24 swift-frontend           0x0000000105c20fe8 swift::AssociatedTypeInference::inferTypeWitnessesViaValueWitnesses(swift::ConformanceChecker&, llvm::SetVector<swift::AssociatedTypeDecl*, std::__1::vector<swift::AssociatedTypeDecl*, std::__1::allocator<swift::AssociatedTypeDecl*> >, llvm::DenseSet<swift::AssociatedTypeDecl*, llvm::DenseMapInfo<swift::AssociatedTypeDecl*, void> > > const&) + 2004
25 swift-frontend           0x0000000105c2866c swift::AssociatedTypeInference::solve(swift::ConformanceChecker&) + 1300
26 swift-frontend           0x0000000105c2a4e4 swift::ConformanceChecker::resolveTypeWitnesses() + 168
27 swift-frontend           0x0000000105bfcfd8 swift::MultiConformanceChecker::checkAllConformances() + 13180
28 swift-frontend           0x0000000105c0bbd8 swift::TypeChecker::checkConformancesInContext(swift::IterableDeclContext*) + 8704
29 swift-frontend           0x0000000105b9c0e8 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 14476
30 swift-frontend           0x0000000105c7e824 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 600
31 swift-frontend           0x0000000105c83a48 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 680
32 swift-frontend           0x0000000105c8370c llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 240
33 swift-frontend           0x0000000105c7e564 swift::performTypeChecking(swift::SourceFile&) + 88
34 swift-frontend           0x0000000104aed630 swift::CompilerInstance::performSema() + 308
35 swift-frontend           0x0000000104953fb0 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 464
36 swift-frontend           0x0000000104952944 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4308
37 swift-frontend           0x000000010491768c swift::mainEntry(int, char const**) + 4116
38 dyld                     0x00000001893e7f28 start + 2236

@simba909
Copy link
Author

Update: Objective-C interop does not seem to be related to the issue; even after converting to Swift the compiler crash persists. I'm working on getting an updated minimally reproducible case.

@hborla hborla removed the triage needed This issue needs more specific labels label Apr 27, 2024
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 missing info Resolution: Is missing crucial info such as a test case or a concise description objective-c interop Feature: Interoperability with Objective-C swift 5.8
Projects
None yet
Development

No branches or pull requests

3 participants