"Incorrect actor executor assumption" run-time error in Swift 6 mode

I have encountered a pretty strange run-time error in Swift 6 mode with the following code:

protocol P {
	var key: String { get }
}

@globalActor
actor GA {
	static var shared = GA()
}

@GA
class A: P {
	let key: String = "SomeKey"
}

let p: P = A()
print(p.key) // <- run-time error here

Looks like it's a result of a combination of a global actor and protocol. If I make A a normal actor, or if I remove the protocol and use an instance of A directly the error is not triggered.

What is the reason for this error and how do I fix it?

Also why would Swift 6 fail at run-time in such a trivial situation when it's supposed to guarantee concurrency safety at compile time?

1 Like

Please include crash/error messages when saying "error here".

It sounds like something similar to what's going on here: Opening actor existentials breaks dynamic isolation checks inserted for @preconcurrency conformances #76507, i.e. something going wrong with the witnessing... We definitely should investigate and fix such.

Please file a github issue, with details about swift versions and exact error message etc.

1 Like

Sorry I should have mentioned that the app crashes with SIGABRT and the last thing I can see in the logs is the phrase "Incorrect actor executor assumption" and nothing else.

Could someone point me where I should file an issue exactly?

The "new issue" button over here: Issues Β· swiftlang/swift Β· GitHub it'll help us track the issue.

Thanks in advance.

1 Like

I ran into the same crash. In may case, I used to have a compiler warning that you can see here. However now, the compiler doesn't complain anymore and crashes.

Following @grynspan's advice, I tried @crontab's snippet by marking the property as async and it did not crash anymore.

protocol P {
    var key: String { get async } // <-- this
}

@globalActor
actor GA {
    static var shared = GA()
}

@GA
class A: P {
    var key: String {
        get async {
            "SomeKey"
        }
    }
}

Task {
    let p: P = await A()
    let key = await p.key
    print(key)
}

Context

Xcode: Version 16.2 (16C5032a)

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0