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

Datarace when accessing State #5

Closed
SwiftyJunnos opened this issue Nov 14, 2024 · 2 comments
Closed

Datarace when accessing State #5

SwiftyJunnos opened this issue Nov 14, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@SwiftyJunnos
Copy link
Member

We should use @unchecked Sendable to use this framework.

@Observable
final class State: @unchecked Sendable {
    ...
}

While documentation says it's totally safe from data-race, it's not true at some situations.
Cannot ensure when, but app crashes at random time when accessing state.
(will comment detailed report when it happens again)

subscript seems suspicious because it's accessing state directly by ReferenceWritableKeyPath, not through StateHandler which is safe as an actor.

@SwiftyJunnos SwiftyJunnos added the bug Something isn't working label Nov 14, 2024
@SwiftyJunnos SwiftyJunnos self-assigned this Nov 14, 2024
@SwiftyJunnos SwiftyJunnos changed the title Data-race when accessing State Datarace when accessing State Nov 14, 2024
@SwiftyJunnos
Copy link
Member Author

Screenshot 2024-11-20 at 15 00 59 Screenshot 2024-11-20 at 15 01 11

Accessing state inside Drip's initializer's closure seems to be a problem.

This state is a reference copy of Dripper's State.
And finally, .run method is asynchronously accessing referenced value state.

Maybe we should make Station's State thread-safe.

@SwiftyJunnos
Copy link
Member Author

Fixed on f6e41cb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant