Skip to content

[6.2][Concurrency] Parent task cancellation must cancel task group itself #80797

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

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Apr 14, 2025

Description: Seems that during refactorings of child cancellations we somehow missed
also cancelling the group itself. It seems we did not have good test
coverage of the addTaskUnlessCancelled somehow and thus this slipped
through.

This would allow tasks to continue getting added even though the "parent task" was cancelled, breaking the contract of the addTaskUnlessCancelled method.

This adds a regression test for addTaskUnlessCancelled and fixes how we
handle the cancellation effect in TaskStatus.

Scope/Impact: Task groups whose parent task is cancelled specifically. Cancellation is idempotent, which makes this fix very safe.

Risk: Low, very low risk chance since we only flip atomically the cancelled bit which was missing.
Testing: Added regression test, confirmed the solution
Reviewed by: @al45tair

Original PR: #80794
Radar: rdar://149177600
resolves #80789

ktoso added 2 commits April 14, 2025 17:43
Seems that during refactorings of child cancellations we somehow missed
also cancelling the group itself. It seems we did not have good test
coverage of the addTaskUnlessCancelled somehow and thus this slipped
through.

This adds a regression test for addTaskUnlessCancelled and fixes how we
handle the cancellation effect in TaskStatus.

resolves swiftlang#80789
resolves rdar://149177600
This way we do the right thing always when cancelling the group;
and we MAY visit the child tasks if we have to.
@ktoso ktoso requested a review from a team as a code owner April 14, 2025 08:47
@ktoso ktoso requested review from al45tair and hborla April 14, 2025 08:48
@ktoso ktoso changed the title [Concurrency] Parent task cancellation must cancel task group itself. [6.2][Concurrency] Parent task cancellation must cancel task group itself Apr 14, 2025
@ktoso
Copy link
Contributor Author

ktoso commented Apr 14, 2025

@swift-ci please test

@ktoso ktoso force-pushed the pick-wip-parent-cancel-must-cancel-group branch from 6cda4f9 to 60a1978 Compare April 14, 2025 10:27
@ktoso
Copy link
Contributor Author

ktoso commented Apr 14, 2025

@swift-ci please test

@ktoso
Copy link
Contributor Author

ktoso commented Apr 14, 2025

CI has some weird llvm issue:

/Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/6.2/llvm-project/compiler-rt/lib/tsan/rtl/tsan_dense_alloc.h:125:40: error: expected expression
  125 |   Block *MapBlock(IndexT idx) { return reinterpret_cast<Block *>(Map(idx)); }
      |                                        ^
1 error generated.

@ktoso
Copy link
Contributor Author

ktoso commented Apr 15, 2025

@swift-ci please test

@ktoso ktoso added concurrency Feature: umbrella label for concurrency language features swift 6.2 labels Apr 15, 2025
@ktoso
Copy link
Contributor Author

ktoso commented Apr 15, 2025

Flaky test? TestSwiftREPLCompletion.py

@ktoso
Copy link
Contributor Author

ktoso commented Apr 15, 2025

@swift-ci please test macOS

@ktoso
Copy link
Contributor Author

ktoso commented Apr 15, 2025

@swift-ci please test Linux

@ktoso
Copy link
Contributor Author

ktoso commented Apr 16, 2025

@swift-ci please test macOS

@ktoso ktoso merged commit 361ebea into swiftlang:release/6.2 Apr 17, 2025
5 checks passed
@ktoso ktoso deleted the pick-wip-parent-cancel-must-cancel-group branch April 17, 2025 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency Feature: umbrella label for concurrency language features swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants