Skip to content

[SR-4567] Race condition in URLSession causes a hang #3876

Closed
@pushkarnk

Description

@pushkarnk
Previous ID SR-4567
Radar None
Original Reporter @pushkarnk
Type Bug
Status Closed
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee @pushkarnk
Priority Medium

md5: 6d5db0ffb21f312b377c92601469a6e1

Issue Description:

The attached test app that makes thousands of API calls to the GitHub API eventually hangs if the timeout on each URLSessionTask is sufficiently high. In the case of a low (or default) timeout value many URLSessionTasks fail with "request timed out" URLError. This hang happens very frequently on Linux but is very intermittent on macOS with swift-corelibs-foundation. No hang/timeout is seen on Darwin with ObjC Foundation.

Note: the test case needs GitHub auth tokens to run.

Passing case:
The number of queued tasks is equal to the number of finished tasks. There should be no instances of URLError.

Queued 5048 tasks until now
...
...
Finished a total of 5048 tasks!

Failing case:
The number of queued tasks is equal to the number of finished tasks. There may be a hang and/or URLError instances in the output.

Queued 934 tasks until now
....
....
....
Finished a total of 332 tasks!
<hang>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions