Skip to content

Compiler crash compiling distributed actor with missing ActorSystem typealias #69996

Closed
@samalone

Description

@samalone

Description
The swift compiler crashes if it encounters a distributed actor definition that
is missing the ActorSystem typelias. This seems similar to #58663

Steps to reproduce

Create a SPM project containing this code:

import Foundation
import Distributed

distributed actor DoesItBlend {
    private var _count = 0
    
    distributed var count: Int {
        get {
            return _count
        }
    }
}

Build the project on the command line with swift build. The compiler crashes with:

swift build
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)
/Volumes/Campfire/Projects/thunk-test/Sources/ThunkTest/ThunkTest.swift:4:19: error: distributed actor 'DoesItBlend' does not declare ActorSystem it can be used with.
distributed actor DoesItBlend {
                  ^
/Volumes/Campfire/Projects/thunk-test/Sources/ThunkTest/ThunkTest.swift:4:13: note: you can provide a module-wide default actor system by declaring:
typealias DefaultDistributedActorSystem = <#ConcreteActorSystem#>

distributed actor DoesItBlend {
            ^
Distributed.DistributedActor:3:20: note: protocol requires nested type 'ActorSystem'; do you want to add it?
    associatedtype ActorSystem : DistributedActorSystem where Self.ID == Self.ActorSystem.ActorID
                   ^
Distributed.DistributedActor:4:20: note: protocol requires nested type 'SerializationRequirement'; do you want to add it?
    associatedtype SerializationRequirement where Self.SerializationRequirement == Self.ActorSystem.SerializationRequirement
                   ^
/Volumes/Campfire/Projects/thunk-test/Sources/ThunkTest/ThunkTest.swift:4:19: error: type 'DoesItBlend' does not conform to protocol 'Encodable'
distributed actor DoesItBlend {
                  ^
Swift.Encodable:2:10: note: protocol requires function 'encode(to:)' with type 'Encodable'
    func encode(to encoder: Encoder) throws
         ^
ThunkTest.DoesItBlend (internal):2:18: note: cannot automatically synthesize 'Encodable' because 'DoesItBlend.ActorSystem.ActorID' does not conform to 'Encodable'
    internal let id: ThunkTest.DoesItBlend.ActorSystem.ActorID
                 ^
ThunkTest.DoesItBlend (internal):3:18: note: cannot automatically synthesize 'Encodable' because 'DoesItBlend.ActorSystem' does not conform to 'Encodable'
    internal let actorSystem: ThunkTest.DoesItBlend.ActorSystem
                 ^
/Volumes/Campfire/Projects/thunk-test/Sources/ThunkTest/ThunkTest.swift:4:19: error: type 'DoesItBlend' does not conform to protocol 'Decodable'
distributed actor DoesItBlend {
                  ^
Swift.Decodable:2:5: note: protocol requires initializer 'init(from:)' with type 'Decodable'
    init(from decoder: Decoder) throws
    ^
ThunkTest.DoesItBlend (internal):2:18: note: cannot automatically synthesize 'Decodable' because 'DoesItBlend.ActorSystem.ActorID' does not conform to 'Decodable'
    internal let id: ThunkTest.DoesItBlend.ActorSystem.ActorID
                 ^
ThunkTest.DoesItBlend (internal):3:18: note: cannot automatically synthesize 'Decodable' because 'DoesItBlend.ActorSystem' does not conform to 'Decodable'
    internal let actorSystem: ThunkTest.DoesItBlend.ActorSystem
                 ^
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Volumes/Campfire/Projects/thunk-test/Sources/ThunkTest/ThunkTest.swift -target x86_64-apple-macosx13.0 -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -I /Volumes/Campfire/Projects/thunk-test/.build/x86_64-apple-macosx/debug -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -module-cache-path /Volumes/Campfire/Projects/thunk-test/.build/x86_64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -module-name ThunkTest -package-name thunk_test -disable-clang-spi -target-sdk-version 14.0 -target-sdk-name macosx14.0 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -emit-module-doc-path /Volumes/Campfire/Projects/thunk-test/.build/x86_64-apple-macosx/debug/ThunkTest.swiftdoc -emit-module-source-info-path /Volumes/Campfire/Projects/thunk-test/.build/x86_64-apple-macosx/debug/ThunkTest.swiftsourceinfo -emit-objc-header-path /Volumes/Campfire/Projects/thunk-test/.build/x86_64-apple-macosx/debug/ThunkTest.build/ThunkTest-Swift.h -emit-dependencies-path /Volumes/Campfire/Projects/thunk-test/.build/x86_64-apple-macosx/debug/ThunkTest.build/ThunkTest.emit-module.d -parse-as-library -o /Volumes/Campfire/Projects/thunk-test/.build/x86_64-apple-macosx/debug/ThunkTest.swiftmodule -emit-abi-descriptor-path /Volumes/Campfire/Projects/thunk-test/.build/x86_64-apple-macosx/debug/ThunkTest.abi.json
1.	Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
2.	Compiling with the current language version
3.	While evaluating request TypeCheckSourceFileRequest(source_file "/Volumes/Campfire/Projects/thunk-test/Sources/ThunkTest/ThunkTest.swift")
4.	While evaluating request TypeCheckFunctionBodyRequest(ThunkTest.(file).DoesItBlend.count())
5.	While evaluating request ParseAbstractFunctionBodyRequest(ThunkTest.(file).DoesItBlend.count())
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           0x0000000109c64a98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1  swift-frontend           0x000000010e740a68 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010e74163e SignalHandler(int) + 270
3  libsystem_platform.dylib 0x00007ff811f3237d _sigtramp + 29
4  swift-frontend           0x000000010b28f444 swift::ConformanceChecker::~ConformanceChecker() + 356
5  swift-frontend           0x000000010ac8c5e4 deriveBodyDistributed_thunk(swift::AbstractFunctionDecl*, void*) + 980
6  swift-frontend           0x000000010b74e20e swift::SimpleRequest<swift::ParseAbstractFunctionBodyRequest, swift::BodyAndFingerprint (swift::AbstractFunctionDecl*), (swift::RequestFlags)4>::evaluateRequest(swift::ParseAbstractFunctionBodyRequest const&, swift::Evaluator&) + 350
7  swift-frontend           0x000000010bb70b52 swift::ParseAbstractFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::ParseAbstractFunctionBodyRequest>(swift::Evaluator&, swift::ParseAbstractFunctionBodyRequest, swift::ParseAbstractFunctionBodyRequest::OutputType) + 1362
8  swift-frontend           0x000000010bae2950 swift::AbstractFunctionDecl::getBody(bool) const + 272
9  swift-frontend           0x000000010b3734a7 swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 167
10 swift-frontend           0x000000010bb7190e swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType) + 1022
11 swift-frontend           0x000000010b422c0b swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 731
12 swift-frontend           0x000000010b42f2ed llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 797
13 swift-frontend           0x000000010e4cb022 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 242
14 swift-frontend           0x0000000109dbf0b9 swift::CompilerInstance::performSema() + 329
15 swift-frontend           0x000000010dedff50 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 560
16 swift-frontend           0x000000010dee8a4c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5532
17 swift-frontend           0x000000010df531c3 swift::mainEntry(int, char const**) + 2035
18 dyld                     0x00007ff811b7c3a6 start + 1942

Expected behavior

The compiler should generate the errors and warnings without crashing.

Environment

  • swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1) Target: x86_64-apple-macosx14.0
  • Xcode version info: Xcode 15.0.1 Build version 15A507
  • Deployment target: .macOS(.v13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.distributedFeature → concurrency: distributed actor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions