Skip to content
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

Avoid double continuation resume in URLSession delegate in corner case #28

Conversation

simonjbeaumont
Copy link
Contributor

Motivation

If the request completes with error after the response has already been received we can potentially resume a continuation twice. This was shown by running some of the tests in long loop.

Modifications

  • Add a shorter test that more reliably reproduced the issue.
  • Add the fix: to set the continuation to nil after resuming it, while still holding the lock.

Result

  • Removed a source of a potential runtime crash.

Test Plan

  • The newly added test, which reliably failed, now reliably passes.

@simonjbeaumont simonjbeaumont marked this pull request as ready for review November 23, 2023 11:44
@simonjbeaumont simonjbeaumont added the semver/patch No public API change. label Nov 23, 2023
@simonjbeaumont simonjbeaumont merged commit 8c84285 into apple:main Nov 23, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants