-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[TaskGroup] Reenable test and fix memory issue #67392
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
[TaskGroup] Reenable test and fix memory issue #67392
Conversation
@swift-ci please smoke test |
test/Concurrency/Runtime/async_taskgroup_discarding_dontLeak_class_error.swift
Outdated
Show resolved
Hide resolved
test/Concurrency/Runtime/async_taskgroup_discarding_dontLeak_class_error.swift
Outdated
Show resolved
Hide resolved
@swift-ci please smoke test |
test/Concurrency/Runtime/async_taskgroup_discarding_dontLeak_class_error.swift
Show resolved
Hide resolved
storing the crash here for reference |
@swift-ci please smoke test linux |
42f4b8c
to
eeb2610
Compare
@swift-ci please smoke test linux |
@swift-ci please test |
Is the PR description out-of-date? Isn't an important correctness fix in the runtime included? |
Yes, updated to CCC style with all the details from #67700 now |
released memory. Because the waitAll() group method is called before the group returns from withTaskGroup and is used to ensure all tasks have completed before we destroy the task group, this method is then immediately followed by calling TaskGroup::destroy. If we, as previously, first resume the waiting task and then attempt to unlock the lock held by the group, we are in an unsafe situation with racing the task group destroy() and the unlock(). Therefore, we must release the lock before we resume the waiting task.
95d5d08
to
d01abcb
Compare
@swift-ci please smoke test |
Rebased, this has only the necessary change right now. |
@swift-ci please smoke test Windows |
@swift-ci please smoke test Linux (CI/github connection issues) |
@swift-ci please smoke test Linux |
1 similar comment
@swift-ci please smoke test Linux |
@swift-ci please smoke test macOS |
Failed Tests (1): |
@swift-ci please smoke test macOS |
Description: This re-enables a task group test and fixes a memory issue where we realized we must release the group lock before resuming the waiting task. If we don't do this, we're racing the group's destroy() (coming from the parent task, waiting on waitAll with the unlock()), risking calling unlock() on already released memory - very rarely causing crashes due to this. It is hard to reproduce this issue, due to the race appearing very rarely, but it is consistently reproducible in some environments.
Risk: Low, the fix reorders an unlock() with the waitingTask resume which cannot cause any other consistency issues as there are no other actions taken after the resume. Arguably, this always should have been release + run order.
Reward: Medium, it seems this crash does not manifest frequently in real applications, however it is a real issue we need to fix.
Review by: @al45tair @erik
Testing: CI testing, confirmed the fix on specially prepared environments.
Radar: rdar://112759360 rdar://110474311