Skip to content

Eliminate race windows in the Socket class #245

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

Merged
merged 4 commits into from
Aug 7, 2025
Merged

Conversation

dkovba
Copy link
Contributor

@dkovba dkovba commented Aug 2, 2025

While individual accesses were properly mutex-protected, the logical operations were not atomic, leading to a potential inconsistency in a multi-threaded environment. Multiple separate state.withLock calls created race windows. With the proposed changes, single atomic operations check and update the state together.

@dkovba dkovba requested a review from dcantah August 2, 2025 01:23
@dkovba dkovba merged commit bfc34e0 into apple:main Aug 7, 2025
2 checks passed
@dkovba dkovba deleted the dkovba/socket branch August 7, 2025 01:23
crosbymichael pushed a commit that referenced this pull request Aug 11, 2025
Improves #245. A potential
deadlock risk was not proven. This PR moves the closing operation inside
the lock to prevent leaking an unclosed handle in case of an error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants