Skip to content

[6.0] Concurrency: Guard TG state with a mutex even with cooperative executor #75047

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

Conversation

kateinoigakukun
Copy link
Member

Explanation: Fixes a potential data race issue in TaskGroup when selecting the cooperative executor as the global executor.
Scope: Bug fix
Issue: N/A
Original PR: #75008
Risk: Low. This change effectively affects only wasm32-unknown-wasip1-threads.
Testing: Locally stress-tested
Reviewer: @ktoso

kateinoigakukun and others added 2 commits July 8, 2024 02:45
`SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY` just means that the global
executor is cooperative, but it doesn't mean that the target platform is
always single-threaded. For example, on wasm32-unknown-wasip1-threads,
the global executor is cooperative, but users can still set up their own
TaskExecutor with multiple threads.

This patch guards the `TaskGroup` state with a mutex even with a
cooperative executor by respecting threading package instead. This
change effectively affects only wasm32-unknown-wasip1-threads.
@kateinoigakukun kateinoigakukun marked this pull request as ready for review July 8, 2024 02:51
@kateinoigakukun kateinoigakukun requested a review from a team as a code owner July 8, 2024 02:51
@kateinoigakukun
Copy link
Member Author

@swift-ci test

@MaxDesiatov MaxDesiatov requested a review from bnbarham July 8, 2024 09:08
@MaxDesiatov MaxDesiatov added Concurrencу Area → standard library: The `Concurrency` module under the standard library umbrella WebAssembly Platform: WebAssembly labels Jul 8, 2024
@kateinoigakukun kateinoigakukun merged commit b9cb872 into swiftlang:release/6.0 Jul 8, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Concurrencу Area → standard library: The `Concurrency` module under the standard library umbrella WebAssembly Platform: WebAssembly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants