Skip to content

[SR-8017] Non-recoverable error while stress-testing URLSession #3675

Open
@swift-ci

Description

@swift-ci
Previous ID SR-8017
Radar None
Original Reporter lwalkin (JIRA User)
Type Bug
Status In Progress
Resolution
Environment

Linux ubuntu-xenial 4.4.0-128-generic #154-Ubuntu SMP Fri May 25 14:15:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
swift -version
Swift version 4.1-dev (LLVM 1c8b50929b, Clang 420ae40df6, Swift b2d7fb958c)
Target: x86_64-unknown-linux-gnu

Additional Detail from JIRA
Votes 2
Component/s Foundation
Labels Bug
Assignee @ahti
Priority Medium

md5: 53f199ac413a677a7f4337be7215113a

Issue Description:

Summary:

Non-recoverable fatal error is produced when operating URL session under stress.

Steps To Reproduce:

The code is along the lines of:

func testURLGetStressTest() throws {
{{ let testData: [UInt8] = [1, 2, 3]}}
{{ let numObjects = 10}}
{{ let objects: [[UInt8]] = try (0 ..< numObjects).map{ _ in}}
{{ let size = random() % 64}}
{{ let data = (0 ..< size).map{ _ in UInt8(random() & 0xFF) }}}
{{ return try CODE_THAT_USES_URLSESSION}}
{{ }}}

{{ // Dispatch a bunch of random requests.}}
{{ DispatchQueue.concurrentPerform(iterations: numObjects * 10) { _ in}}
{{ let object = objects[random() % objects.count]}}
{{ let (statusCode, response) = try! getContents(url: "http://127.0.0.1:(port)/(object)")}}
{{ }}}
{{ }}}

Results:

Fatal error: Trying to access a behaviour for a task that in not in the registry.: file Foundation/URLSession/TaskRegistry.swift, line 105

Irrespectively of how this code can be triggered, and whether this thing is easily reproducible, it shouldn't generate a fatal error in the first place. Should be something the application code can recover from.

Notes:

The system is specifically placed under stress by this test, either from the point of view of file descriptor, or DispatchQueue threads, or something like that.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions