🍒[5.9][TaskGroup] Reenable test and fix memory issue #67700
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 onwaitAll
with theunlock()
), risking callingunlock()
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.
Original PR: #67392
Radar: rdar://112759360 rdar://110474311