Surprising actor deinitialization #77365
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
concurrency
Feature: umbrella label for concurrency language features
Description
I have been using Xcode 16 for a few weeks now and noticed a behavior regarding
actor
deinitialization that surprises me.In our app, we use a few actors that are stored as constant static properties and thus live as long as the app is not killed. Compiling with Xcode 16, we have noticed that capturing the actor as
unowned
lead to a crash in several cases, like aTask
initialization (even though for aTask
, capturingself
asunowned
is unneeded most of the time).Reproduction
To exemplify this, here's a block of code for a command-line tool.
Here's what is printed in the console.
Expected behavior
The
deinit
block should not be called, as theactor
is stored as a static constant property and thus should live as long as the application or command-line tool lives.Environment
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0
Note
I never had the issue before using Xcode 16.
Additional information
The behavior differs when a
class
is used instead of anactor
, which lead me to think this might be a bug.The issue is mentioned in the Swift Forums.
The text was updated successfully, but these errors were encountered: