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

[SR-15595] Actors can become indefinitely reserved. #57898

Closed
kavon opened this issue Dec 14, 2021 · 4 comments
Closed

[SR-15595] Actors can become indefinitely reserved. #57898

kavon opened this issue Dec 14, 2021 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@kavon
Copy link
Contributor

kavon commented Dec 14, 2021

Previous ID SR-15595
Radar rdar://problem/86482007
Original Reporter @kavon
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

macOS; reproduces on `main` and Swift 5.5

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @rjmccall
Priority Medium

md5: 01e747a08c7538b6c2c29bcf7aa1d229

Issue Description:

If an ordinary async function calls an async actor-instance's method and then does some long-running work that does not interact with an actor, then that actor-instance can become indefinitely reserved, preventing other tasks from making progress. See attachment for minimal reproducer and expected output.

@kavon
Copy link
Contributor Author

kavon commented Dec 14, 2021

@swift-ci create

@marcomasser
Copy link

Thanks for creating this issue and for the concise reproducer, @kavon! For a bit more context to what I asked on the forums:

I ran into this issue while migrating a Vapor code base to async/await. Some unit test methods are marked as async and call various other async methods, none of them actor isolated. The unit tests then also use some mock objects that used to be classes but that I migrated to actors (because they have mutable state and my understanding of Swift’s concurrency features makes me think that’s the right thing to do here). As soon as I migrated the mocks to actors, some calls to them caused the unit tests to hang. Those calls were simple property accesses like in print(await mock.requestCount)

@kavon
Copy link
Contributor Author

kavon commented Feb 3, 2022

This problem was resolved on main in this PR and in release/5.6 in this PR as part of SE-338

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@marcomasser
Copy link

This problem was resolved on main in this PR and in release/5.6 in this PR as part of SE-338

Just FYI: This issue is not resolved in Swift 5.6 as it ships with Xcode 13.4.0, as can be verified with the attached sample code. It is resolved in Swift 5.7 that ships with the Xcode 14 Betas, though.

This issue was closed.
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
Projects
None yet
Development

No branches or pull requests

2 participants